bdc call transaction

Solutions on MaxInterview for bdc call transaction by the best coders in the world

showing results for - "bdc call transaction"
Nicole
29 Aug 2020
1REPORT ZSAPN_BDC
2       NO STANDARD PAGE HEADING LINE-SIZE 255.
3
4TYPES: BEGIN OF TY_MARA, "user defined types as per flat file
5       MATNR TYPE MARA-MATNR,
6       MBRSH TYPE MARA-MBRSH,
7       MTART TYPE MARA-MTART,
8       MEINS TYPE MARA-MEINS,
9       MAKTX TYPE MAKT-MAKTX,
10       END OF TY_MARA.
11DATA : IT_MARA TYPE TABLE OF TY_MARA, "mara internal table
12       WA_MARA TYPE TY_MARA. "mara work area
13DATA: IT_BDCDATA TYPE TABLE OF BDCDATA . "BDCDATA
14DATA: WA_BDCDATA TYPE BDCDATA . "work area BDCDATA
15DATA : BDCMSG TYPE TABLE OF BDCMSGCOLL. "BDC message table
16DATA:FILE TYPE STRING. "file name
17PARAMETERS : P_FILE TYPE RLGRAP-FILENAME. "input parameter for file upload
18
19START-OF-SELECTION.
20  IF P_FILE IS NOT INITIAL.
21    FILE = P_FILE.
22    CALL FUNCTION 'GUI_UPLOAD' "upload flat file
23      EXPORTING
24        FILENAME            = FILE "file name
25        FILETYPE            = 'ASC' "file type
26        HAS_FIELD_SEPARATOR = 'X' "is tab delimited
27      TABLES
28        DATA_TAB            = IT_MARA.
29    IF SY-SUBRC <> 0.
30* Implement suitable error handling here
31    ENDIF.
32
33  ENDIF.
34  LOOP AT IT_MARA INTO WA_MARA. "loop all records and pass one by one to BDC
35    PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '0060'.
36    PERFORM BDC_FIELD       USING 'BDC_CURSOR'
37                                  'RMMG1-MTART'.
38    PERFORM BDC_FIELD       USING 'BDC_OKCODE'
39                                  'ENTR'.
40    PERFORM BDC_FIELD       USING 'RMMG1-MATNR'
41                                  WA_MARA-MATNR. "pass material no
42    PERFORM BDC_FIELD       USING 'RMMG1-MBRSH'
43                                  WA_MARA-MBRSH. "pass indistry sector
44    PERFORM BDC_FIELD       USING 'RMMG1-MTART'
45                                  WA_MARA-MTART. "pass material type
46    PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '0070'.
47    PERFORM BDC_FIELD       USING 'BDC_CURSOR'
48                                  'MSICHTAUSW-DYTXT(01)'.
49    PERFORM BDC_FIELD       USING 'BDC_OKCODE'
50                                  '=ENTR'.
51    PERFORM BDC_FIELD       USING 'MSICHTAUSW-KZSEL(01)'  "select basic view1
52                                  'X'.
53    PERFORM BDC_DYNPRO      USING 'SAPLMGMM' '4004'.
54    PERFORM BDC_FIELD       USING 'BDC_OKCODE'
55                                  '=BU'.
56    PERFORM BDC_FIELD       USING 'MAKT-MAKTX'
57                                  WA_MARA-MAKTX. "pass material description
58    PERFORM BDC_FIELD       USING 'BDC_CURSOR'
59                                  'MARA-MEINS'.
60    PERFORM BDC_FIELD       USING 'MARA-MEINS'
61                                  WA_MARA-MEINS. "pass base unit oe meassure
62
63    CALL TRANSACTION 'MM01' USING IT_BDCDATA "call transaction
64                          MODE 'N' "N-no screen mode, A-all screen mode, E-error screen mode
65                          UPDATE 'A' "A-assynchronous, S-synchronous
66                          MESSAGES INTO  BDCMSG. "messages
67    IF SY-SUBRC EQ 0.
68      WRITE :/  WA_MARA-MATNR, 'submitted to BDC'.
69    ENDIF.
70
71  ENDLOOP.
72
73  DATA : WA_BDCMSG LIKE LINE OF BDCMSG.
74  IF BDCMSG IS NOT INITIAL. "display messages
75    LOOP AT BDCMSG INTO WA_BDCMSG.
76      WRITE:/ WA_BDCMSG-TCODE, WA_BDCMSG-MSGTYP, WA_BDCMSG-MSGV1, WA_BDCMSG-FLDNAME .
77      CLEAR WA_BDCMSG.
78    ENDLOOP.
79  ENDIF.
80FORM BDC_DYNPRO USING PROGRAM DYNPRO.
81  CLEAR WA_BDCDATA.
82  WA_BDCDATA-PROGRAM  = PROGRAM. "program
83  WA_BDCDATA-DYNPRO   = DYNPRO. "screen
84  WA_BDCDATA-DYNBEGIN = 'X'. "begin
85  APPEND WA_BDCDATA TO IT_BDCDATA..
86ENDFORM.
87
88FORM BDC_FIELD USING FNAM FVAL.
89*  IF FVAL <> NODATA.
90  CLEAR WA_BDCDATA.
91  WA_BDCDATA-FNAM = FNAM. "field name ex: matnr
92  WA_BDCDATA-FVAL = FVAL. "field value ex: testmat001
93  APPEND WA_BDCDATA TO IT_BDCDATA.
94*  ENDIF.
95ENDFORM.
96
queries leading to this page
bdc with transactionbdc call transaction