Make your own free website on Tripod.com
 

SAP ABAP Programming, Functional and Basis Components Books


BDC_INSERT functions

You need to go to transaction SM35, to process the Batch Input Session.

BDC_INSERT function is use for uploading data to your SAP dialog program.  e.g. upload data from your MS-DOS text files to your Material Master.   (normally during the initial transit period)

It is also used for modifying your SAP dialog program.  e.g. set the flag for deletion for a range of Purchase Requisition items.

This function comes in handy when you want to mass-update a certain field in the dialog screen.  e.g. changing all the Material Master price control from 'V' to 'S' etc.

You specify the flow of the dialog sceen on your program.

Click System -> Status -> Look for the field Program (screen)

In 4.6x, you could use transaction SHDB to record the transaction.

Example of BDC_INSERT functions to set the flag for deletion for Purchase Requisition.

***********************************************************************
* Program to set the flag for deletion for Purchase Requisition
***********************************************************************

REPORT ZSETFLAG.
TABLES: EBAN.

PARAMETERS  P-BTCHSN(12)  DEFAULT 'ME52CHANGE'.     " Upload session
SELECT-OPTIONS P-BANFN  FOR EBAN-BANFN.

* INTERNAL TABLE FOR DATA
DATA:  BEGIN OF ULTAB OCCURS 50,
         BANFN LIKE EBAN-BANFN,   "Purchase Requisition No.
         BNFPO LIKE EBAN-BNFPO,   "Purchase Req. Item No.
      END OF ULTAB.

* INTERNAL TABLE FOR BATCH INPUT DATA
DATA: BEGIN OF IPUTTAB OCCURS 50.
        INCLUDE STRUCTURE BDCDATA.
DATA: END OF IPUTTAB.

DATA: C_TAXKM LIKE MG03STEUER-TAXKM VALUE '1',
      W-LINE-NO TYPE I.

REFRESH ULTAB.
SELECT * FROM EBAN.
   CHECK P-BANFN.
   ULTAB-BANFN = EBAN-BANFN.
   ULTAB-BNFPO = EBAN-BNFPO.
   APPEND ULTAB.
ENDSELECT.

* Create Batch session
  PERFORM CRE-BATCH-SESS.

** LOOP TABLE TO CREATE SCREEN INPUT
LOOP AT ULTAB.
  REFRESH IPUTTAB.
  PERFORM PRN_ULTAB.
  PERFORM SCREEN1.
  PERFORM SCREEN2.
ENDLOOP.
PERFORM SAVE-SESS.
PERFORM CLOSE-SESS.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
* END OF MAIN PROGRAM

FORM SCREEN1.
* SCREEN #1: MODIFY SCREEN FOR CHANGING PURCHASE REQUISITOIN
  CLEAR IPUTTAB.
  IPUTTAB-PROGRAM = 'SAPMM06B'.
  IPUTTAB-DYNPRO  =  '105'.
  IPUTTAB-DYNBEGIN = 'X'.
  APPEND IPUTTAB.

* PURCHASE REQUISITION NO
     CLEAR IPUTTAB.
     IPUTTAB-FNAM = 'EBAN-BANFN'.
     IPUTTAB-FVAL = ULTAB-BANFN.
     APPEND IPUTTAB.

ENDFORM.
***********************************************************************
* FORM        : SCREEN1                                               *
***********************************************************************
FORM SCREEN2.
* Modify screen for Purchase Requisition
  CLEAR IPUTTAB.
  IPUTTAB-PROGRAM = 'SAPMM06B'.
  IPUTTAB-DYNPRO  =  '101'.
  IPUTTAB-DYNBEGIN = 'X'.
  APPEND IPUTTAB.

IF EBAN-LOEKZ = SPACE.
  CLEAR IPUTTAB.
  IPUTTAB-FNAM = 'RM06B-SELKZ(1)'.
  IPUTTAB-FVAL = 'X'.
  APPEND IPUTTAB.

  CLEAR IPUTTAB.
  IPUTTAB-FNAM = 'BDC_OKCODE'.
  IPUTTAB-FVAL = 'DL'.
  APPEND IPUTTAB.
ENDIF.

ENDFORM.

FORM SAVE-SESS.
  CLEAR IPUTTAB.
  IPUTTAB-PROGRAM = 'SAPMM06B'.
  IPUTTAB-DYNPRO  =  '101'.
  IPUTTAB-DYNBEGIN = 'X'.
  APPEND IPUTTAB.

* Specify that we are now done with this screen (Save it with F11)
  CLEAR IPUTTAB.
  IPUTTAB-FNAM = 'BDC_OKCODE'.
  IPUTTAB-FVAL = '/11'.
  APPEND IPUTTAB.
ENDFORM.

***********************************************************************
* FORM        : CLOSE-SESS                                            *
* DESCRIPTION : CLOSE THE SESSION                                     *
***********************************************************************
FORM CLOSE-SESS.
* closing the session.
  CALL FUNCTION 'BDC_INSERT'
       EXPORTING
            TCODE     = 'ME52'
       TABLES
            DYNPROTAB = IPUTTAB.
ENDFORM.

***********************************************************************
* FORM        : PRN-ULTAB                                             *
* DESCRIPTION : PRINT OK TABLE                                        *
***********************************************************************
FORM PRN_ULTAB.
  WRITE: / ULTAB-BANFN.
  W-LINE-NO = W-LINE-NO + 1.
WRITE: '      RECORD# ', W-LINE-NO.
ENDFORM.

***********************************************************************
* FORM        : CRE-BATCH-SESS                                        *
* DESCRIPTION : CREATE BATCH SESSION                    *
***********************************************************************
FORM CRE-BATCH-SESS.
** Create BTCI session **
CALL FUNCTION 'BDC_OPEN_GROUP'
     EXPORTING
          CLIENT = SY-MANDT
          GROUP  = P-BTCHSN
          USER   = SY-UNAME
          KEEP   = 'X'.
ENDFORM.

Back to Previous

Return to SAP Hints and Tips on Configuration and ABAP/4 Programming