Creating a simple database table using BDC

By Banupriya R, YASH Technologies

Report ypriyatest.
TABLES:
      bdcdata.
DATA:t_bdcdata LIKE
        STANDARD TABLE
        OF bdcdata.
PARAMETERS :
   p_table(15) TYPE c.
DATA:
  MSG LIKE BDCMSGCOLL,
  T_MSG LIKE TABLE OF MSG,
  MESSAGE(72) TYPE C.
PERFORM PROCESS.
*&---------------------------------------------------------------------
*
*&      Form  fill_screendata
*&---------------------------------------------------------------------

form fill_screendata  using    value(p_0015)
                               value(p_0016).
  BDCDATA-PROGRAM = P_0015.
  BDCDATA-DYNPRO  = P_0016.
  BDCDATA-DYNBEGIN = 'X'.
  APPEND BDCDATA TO T_BDCDATA.
 CLEAR BDCDATA.
endform.                    " fill_screendata
*&---------------------------------------------------------------------
*
*&      Form  FILL_FIELD_DATA
*&---------------------------------------------------------------------

form FILL_FIELD_DATA  using    value(p_0020)
                               value(p_0021).
  BDCDATA-FNAM = P_0020.
  BDCDATA-FVAL = P_0021.
  APPEND BDCDATA TO T_BDCDATA.
 CLEAR BDCDATA.
 endform.                    " FILL_FIELD_DATA
*&---------------------------------------------------------------------
*
*&      Form  PROCESS
*&---------------------------------------------------------------------

form PROCESS .
**first screen
PERFORM fill_screendata
   USING 'SAPMSRD0' '0102'.
PERFORM FILL_FIELD_DATA
   USING 'RSRD1-TBMA' 'X'.
PERFORM FILL_FIELD_DATA
   USING 'RSRD1-TBMA_VAL' p_table.
PERFORM FILL_FIELD_DATA
   USING 'BDC_OKCODE' '=ADD'.
**second screen
PERFORM fill_screendata
   USING 'SAPLSD41' '2200'.
PERFORM FILL_FIELD_DATA
   USING 'DD02D-DDTEXT' 'Bdc Table'.
PERFORM FILL_FIELD_DATA
   USING 'DD02D-CONTFLAG' 'A'.
PERFORM FILL_FIELD_DATA
   USING 'DD02D-MAINFLAG' 'X'.
PERFORM FILL_FIELD_DATA
   USING 'BDC_OKCODE' '=CHANGE_MAINTFLAG'.
PERFORM FILL_FIELD_DATA
   USING 'BDC_OKCODE' '/00'.
PERFORM FILL_FIELD_DATA
   USING 'BDC_OKCODE' '=DEF'.
**second screen filling table fields
PERFORM fill_screendata
   USING 'SAPLSD41' '2200'.
PERFORM FILL_FIELD_DATA
   USING 'DD03P-FIELDNAME(01)' 'mandt'.
PERFORM FILL_FIELD_DATA
   USING 'DD03P-FIELDNAME(02)' 'name'.
PERFORM FILL_FIELD_DATA
   USING 'DD03P-FIELDNAME(03)' 'empid'.
PERFORM FILL_FIELD_DATA
   USING 'DD03D-ROLLNAME(01)' 'mandt'.
PERFORM FILL_FIELD_DATA
   USING 'DD03D-ROLLNAME(02)' 'char20'.
PERFORM FILL_FIELD_DATA
   USING 'DD03D-ROLLNAME(03)' 'numc4'.
PERFORM FILL_FIELD_DATA
   USING 'DD03P-KEYFLAG(01)' 'X'.
PERFORM FILL_FIELD_DATA
   USING 'BDC_OKCODE' '/00'.
PERFORM FILL_FIELD_DATA
   USING 'BDC_OKCODE' '=WB_SAVE'.
**saving the table****
PERFORM fill_screendata
   USING 'SAPLSTRD' '0100'.
PERFORM FILL_FIELD_DATA
   USING 'KO007-L_DEVCLASS' '$TMP'.
PERFORM FILL_FIELD_DATA
   USING 'KO007-L_AUTHOR' 'SAPDEV02'.
PERFORM FILL_FIELD_DATA
   USING 'BDC_OKCODE' '=TEMP'.
**filling technical settings.
PERFORM fill_screendata
   USING 'SAPLSD41' '2200'.
PERFORM FILL_FIELD_DATA
   USING 'BDC_OKCODE' '=SE13'.
PERFORM fill_screendata
   USING 'SAPMSEDS' '0050'.
PERFORM FILL_FIELD_DATA
   USING 'BDC_CURSOR' 'DD09V-TABART'.
PERFORM FILL_FIELD_DATA
   USING 'DD09V-TABART' 'APPL0'.
PERFORM FILL_FIELD_DATA
   USING 'DD09V-TABKAT' '0'.
PERFORM FILL_FIELD_DATA
   USING 'ALLOWSTATE-NOT_ALLOWED' 'X'.
PERFORM FILL_FIELD_DATA
   USING 'BDC_OKCODE' '=SICH'.
PERFORM fill_screendata
   USING 'SAPMSEDS' '0050'.
PERFORM FILL_FIELD_DATA
   USING 'BDC_OKCODE' '=BACK'.
PERFORM fill_screendata
   USING 'SAPLSD41' '2200'.
PERFORM FILL_FIELD_DATA
   USING 'BDC_OKCODE' '=WB_SAVE'.
PERFORM fill_screendata
   USING 'SAPLSD41' '2200'.
PERFORM FILL_FIELD_DATA
   USING 'BDC_OKCODE' '=WB_CHECK'.
PERFORM fill_screendata
   USING 'SAPLSD41' '2200'.
PERFORM FILL_FIELD_DATA
   USING 'BDC_OKCODE' '=WB_ACTIVATE'.
PERFORM FILL_SCREENDATA
    USING 'SAPLSEWORKINGAREA' '0205'.
PERFORM FILL_FIELD_DATA
    USING 'BDC_OKCODE' '=WEIT'.
PERFORM fill_screendata
   USING 'SAPLSD41' '2200'.
PERFORM FILL_FIELD_DATA
   USING 'BDC_OKCODE' '=BACK'.
PERFORM fill_screendata
   USING 'SAPMSRD0' '0102'.
PERFORM FILL_FIELD_DATA
   USING 'BDC_OKCODE' '=BACK'.
CALL TRANSACTION 'SE11' USING T_BDCDATA MODE 'A' MESSAGES INTO T_MSG.
LOOP AT T_MSG INTO MSG.
CALL FUNCTION 'FORMAT_MESSAGE'
 EXPORTING
   ID              = MSG-MSGID
   LANG            = 'EN'
   NO              = MSG-MSGNR
   V1              = MSG-MSGV1
   V2              = MSG-MSGV2
   V3              = MSG-MSGV3
   V4              = MSG-MSGV4
 IMPORTING
   MSG             = MESSAGE
 EXCEPTIONS
   NOT_FOUND       = 1
   OTHERS          = 2
          .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF sy-subrc EQ 0.
      WRITE / MESSAGE.
    ENDIF.
ENDLOOP.
endform.                    " PROCESS

Output

First Screen

Click here to continue...

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image