Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Call session Method of BDC

1,611 views

Published on

Hi This is a Sample Code of Call Session Method of BDC (Batch Data Conversion).

Published in: Education
  • Be the first to comment

  • Be the first to like this

Call session Method of BDC

  1. 1. REPORT ZBDC_004 NO STANDARD PAGE HEADING LINE-SIZE 255. *INCLUDE BDCRECX1. TYPES: BEGIN OF T_TAB, PERNR TYPE ZTAB_001-PERNR, ENAME TYPE ZTAB_001-ENAME, CITY TYPE ZTAB_001-CITY, END OF T_TAB. DATA: D_FILE TYPE STRING, BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE, MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE, IT_DATA TYPE TABLE OF T_TAB, WA_DATA TYPE T_TAB. PARAMETERS: P_FILE TYPE IBIPPARMS-PATH OBLIGATORY. AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE. CALL FUNCTION 'F4_FILENAME' IMPORTING FILE_NAME = P_FILE. D_FILE = P_FILE.
  2. 2. CALL FUNCTION 'GUI_UPLOAD' EXPORTING FILENAME FILETYPE = D_FILE = 'ASC' HAS_FIELD_SEPARATOR = 'X' * HEADER_LENGTH =0 * READ_BY_LINE * DAT_MODE ='' * CODEPAGE ='' * IGNORE_CERR = ABAP_TRUE * REPLACEMENT = '#' * CHECK_BOM * VIRUS_SCAN_PROFILE * NO_AUTH_CHECK = 'X' ='' = ='' * IMPORTING * FILELENGTH * HEADER = = TABLES DATA_TAB = IT_DATA EXCEPTIONS FILE_OPEN_ERROR =1 FILE_READ_ERROR =2 NO_BATCH =3 GUI_REFUSE_FILETRANSFER =4
  3. 3. INVALID_TYPE =5 NO_AUTHORITY =6 UNKNOWN_ERROR =7 BAD_DATA_FORMAT =8 HEADER_NOT_ALLOWED =9 SEPARATOR_NOT_ALLOWED HEADER_TOO_LONG = 10 = 11 UNKNOWN_DP_ERROR ACCESS_DENIED = 12 = 13 DP_OUT_OF_MEMORY DISK_FULL = 15 DP_TIMEOUT OTHERS = 14 = 16 = 17. IF SY-SUBRC <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. START-OF-SELECTION. PERFORM OPEN_GROUP. LOOP AT IT_DATA INTO WA_DATA. PERFORM BDC_DYNPRO PERFORM BDC_FIELD USING 'SAPMSVMA' '0100'. USING 'BDC_CURSOR'
  4. 4. 'VIEWNAME'. PERFORM BDC_FIELD USING 'BDC_OKCODE' '=UPD'. PERFORM BDC_FIELD USING 'VIEWNAME' 'ZTAB_001'. PERFORM BDC_FIELD USING 'VIMDYNFLDS-LTD_DTA_NO' 'X'. PERFORM BDC_DYNPRO PERFORM BDC_FIELD USING 'SAPLZTAB_001' '0100'. USING 'BDC_CURSOR' 'ZTAB_001-PERNR(01)'. PERFORM BDC_FIELD USING 'BDC_OKCODE' '=NEWL'. PERFORM BDC_DYNPRO PERFORM BDC_FIELD USING 'SAPLZTAB_001' '0100'. USING 'BDC_CURSOR' 'ZTAB_001-CITY(01)'. PERFORM BDC_FIELD USING 'BDC_OKCODE' '=SAVE'. PERFORM BDC_FIELD USING 'ZTAB_001-PERNR(01)' WA_DATA-PERNR. PERFORM BDC_FIELD USING 'ZTAB_001-ENAME(01)' WA_DATA-ENAME. PERFORM BDC_FIELD USING 'ZTAB_001-CITY(01)' WA_DATA-CITY. PERFORM BDC_DYNPRO PERFORM BDC_FIELD USING 'SAPLZTAB_001' '0100'. USING 'BDC_CURSOR'
  5. 5. 'ZTAB_001-PERNR(02)'. PERFORM BDC_FIELD USING 'BDC_OKCODE' '=BACK'. PERFORM BDC_DYNPRO PERFORM BDC_FIELD USING 'SAPLZTAB_001' '0100'. USING 'BDC_CURSOR' 'ZTAB_001-PERNR(02)'. PERFORM BDC_FIELD USING 'BDC_OKCODE' '=BACK'. PERFORM BDC_DYNPRO PERFORM BDC_FIELD USING 'SAPMSVMA' '0100'. USING 'BDC_OKCODE' '/EBACK'. PERFORM BDC_FIELD USING 'BDC_CURSOR' 'VIEWNAME'. PERFORM BDC_TRANSACTION USING 'SM30'. CLEAR: BDCDATA, BDCDATA[]. ENDLOOP. PERFORM CLOSE_GROUP. *&---------------------------------------------------------------------* *& Form OPEN_GROUP *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text
  6. 6. * <-- p2 text *----------------------------------------------------------------------* FORM OPEN_GROUP . CALL FUNCTION 'BDC_OPEN_GROUP' EXPORTING CLIENT * DEST = SY-MANDT = FILLER8 GROUP = 'MAYUR' HOLDDATE = SY-DATUM KEEP = 'X' USER = SY-UNAME * RECORD = FILLER1 * PROG = SY-CPROG * DCPFM = '%' * DATFM = '%' * IMPORTING * QID = EXCEPTIONS CLIENT_INVALID =1 DESTINATION_INVALID GROUP_INVALID =2 =3 GROUP_IS_LOCKED =4 HOLDDATE_INVALID =5 INTERNAL_ERROR =6
  7. 7. QUEUE_ERROR RUNNING =7 =8 SYSTEM_LOCK_ERROR USER_INVALID OTHERS =9 = 10 = 11. IF SY-SUBRC <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. ENDFORM. " OPEN_GROUP *&---------------------------------------------------------------------* *& Form BDC_DYNPRO *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_0167 text * -->P_0168 text *----------------------------------------------------------------------* FORM BDC_DYNPRO USING PROGRAM DYNPRO. CLEAR BDCDATA. BDCDATA-PROGRAM = PROGRAM. BDCDATA-DYNPRO = DYNPRO.
  8. 8. BDCDATA-DYNBEGIN = 'X'. APPEND BDCDATA. ENDFORM. " BDC_DYNPRO *&---------------------------------------------------------------------* *& Form BDC_FIELD *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_0172 text * -->P_0173 text *----------------------------------------------------------------------* FORM BDC_FIELD USING FNAM FVAL. CLEAR BDCDATA. BDCDATA-FNAM = FNAM. BDCDATA-FVAL = FVAL. APPEND BDCDATA. ENDFORM. " BDC_FIELD *&---------------------------------------------------------------------* *& Form BDC_TRANSACTION *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------*
  9. 9. * -->P_0282 text *----------------------------------------------------------------------* FORM BDC_TRANSACTION USING TCODE. CALL FUNCTION 'BDC_INSERT' EXPORTING TCODE = TCODE * POST_LOCAL = NOVBLOCAL * PRINTING * SIMUBATCH ='' * CTUPARAMS ='' = NOPRINT TABLES DYNPROTAB = BDCDATA EXCEPTIONS INTERNAL_ERROR NOT_OPEN =1 =2 QUEUE_ERROR =3 TCODE_INVALID =4 PRINTING_INVALID =5 POSTING_INVALID =6 OTHERS = 7. IF SY-SUBRC <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF.
  10. 10. ENDFORM. " BDC_TRANSACTION *&---------------------------------------------------------------------* *& Form CLOSE_GROUP *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM CLOSE_GROUP . CALL FUNCTION 'BDC_CLOSE_GROUP' EXCEPTIONS NOT_OPEN = 1 QUEUE_ERROR = 2 OTHERS = 3. IF SY-SUBRC <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. ENDFORM. " CLOSE_GROUP

×