Source Code Documentation
000050 ***********************************************************************
000060 * Program         : ZSA00001
000070 * Title           : Program to populate material master
000080 * Description     : This program prepares data to populate material
000090 *                   master using transaction 'MMR1'(Raw material).
000100 * Assumption      : 1. Only for Industry sector = 'M' (Mechanical Engg.)
000110 * User Inputs
000120 * Parameters      : Filename   - Sequential file having material data to
000130 *                                be inserted into SAP Material master.
000140 *                   Records per Session - No of records in each batch
000150 *                                         session prepared.
000160 *                   Check only - Choose it only to check the datafile
000170 *                                otherwise it will check and make the
000180 *                                sessions.
000190 ************************************************************************
 

Example of Transfer transaction data tables to BDCTAB
001050 *---------------------------------------------------------------------*
001060 *      Form  insert_trxns_in_bdctab
001070 *  Reads the data into the table bdctab in the required sap format    *
001080 *  from table itab.                                                   *
001090 *  if the material already exists it gives a message and continues.   *
001100 *---------------------------------------------------------------------*
001110 form insert_trxns_in_bdctab.
001120 clear bdctab.
001130 perform fill_bdc using :
001140              'X' 'SAPLMGMM'    '60',
001150 *            ' ' 'RMMG1-MATNR' TXN_DATA-ZMATNR ,
001160              ' ' 'RMMG1-MBRSH' 'M',    " Hard Coded
001170              ' ' 'BDC_OKCODE'  'AUSW'.
001180  perform fill_bdc using :
001190          'X' 'SAPLMGMM'    '70',
001200           ' ' 'MSICHTAUSW-KZSEL(1)' 'X'  ,
001210 *       ' ' 'MSICHTAUSW-KZSEL' 'X'  ,
001220          ' ' 'BDC_OKCODE'  '/00'.
001230
001240   perform fill_bdc using :
001250              'X' 'SAPLMGMM'    '3004',
001260              ' ' 'MAKT-MAKTX' txn_data-zmaktx ,
001270 *            ' ' 'SKTEXT-SPRAS' SY-LANGU,
001280 *            ' ' 'SKTEXT-MAKTX' TXN_DATA-ZMAKTX ,
001290              ' ' 'MARA-MEINS' txn_data-zmeins,
001300              ' ' 'MARA-BISMT' txn_data-zbismt,
001310              ' ' 'MARA-SPART' txn_data-spart,
001320              ' ' 'BDC_OKCODE'  'BU'.
001330 endform.

000990 *---------------------------------------------------------------------*
001000 *      Form  FILL_BDC                                                 *
001010 *  Fills table bdctab.                                               *
001020 *---------------------------------------------------------------------*
001030 form fill_bdc using dynbegin fname fval.
001040   clear bdctab.
001050   if dynbegin = 'X'.
001060     move : fname to bdctab-program,
001070            fval to bdctab-dynpro,
001080            'X'  to bdctab-dynbegin.
001090   else.
001100     move : fname to bdctab-fnam,
001110            fval  to bdctab-fval.
001120   endif.
001130   append bdctab.
001140 endform.                               " FILL_BDC
001150
 
 

Example of Open BTCI session
001710 form bdc_open_group.
001720
001730   call function 'BDC_OPEN_GROUP'
001740       exporting
001750             client              = sy-mandt
001760 *           DEST                = FILLER8
001770             group               = newname
001780 *           HOLDDATE            = FILLER8
001790 *           KEEP                = FILLER1
001800             user                =  sy-uname
001810 *     importing
001820 *           qid                 =
001830        exceptions
001840             client_invalid      = 1
001850             destination_invalid = 2
001860             group_invalid       = 3
001870             group_is_locked     = 4
001880             holddate_invalid    = 5
001890             internal_error      = 6
001900             queue_error         = 7
001910             running             = 8
001920             system_lock_error   = 9
001930             user_invalid        = 10.
001940
001950   if sy-subrc = 1.
001960     message e112(zt).
001970   endif.
001980 endform.
 

Example of Transfer BDCTAB to sessions
001440 *    Transfer data to batch input by transaction.
001450 *---------------------------------------------------------------------
001460 * call function 'BDC_INSERT'
001470 *      exporting
001480 *           tcode          = trcode
001490 *      tables
001500 *           dynprotab      = bdctab
001510 *      exceptions
001520 *           internal_error = 1
001530 *           not_open       = 2
001540 *           queue_error    = 3
001550 *           tcode_invalid  = 4
001560 *           others         = 5.
001570
001660 endform.                               " INSERT_GROUP         
 

Example of Close BTCI session

001150
001160 *---------------------------------------------------------------------*
001170 *      Form  CLOSE_GROUP                                              *
001180 *   Closes queue after storing batch input data.                      *
001190 *---------------------------------------------------------------------*
001200 form close_group.
001210   call function 'BDC_CLOSE_GROUP'
001220        exceptions
001230             not_open    = 1
001240             queue_error = 2
001250             others      = 3.
001260 endform.                               " CLOSE_GROUP
001270