Skip to Content
author's profile photo Former Member
Former Member

Hi TO All ABAP Experts,

I am very new to ABAP Programming,I went through all of the posts related to BDC in sdn forum.I have got a clear understanding of BDC.I tried most of the example code and screen short,but none of them working fine.

Can anybody send the screen shorts from SHDB(recording ) from start to end with text file format used

for uploading corresponding information in bdc.If it is related toVA01 or migration of data from external file to sap r/3 on Material master using session method ,it will be great.

Other wise Please send me any bdc program you done in a real time environment.

my mail id is namrathavarma@hotmail.com

Thanks and Regards

Namratha

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Mar 21, 2008 at 08:40 AM

    Hello Namratha,

    Go through these steps for recording by using SHDB.

    How to use recording

    Go to SHDB

    --> Click on New Recording

    --> Provide any name in Recording , For ex: Z_CHAITU

    --> Provide the Transaction name as “MM01”

    --> Select the update mode as Synchrounous or Asynchrounus method

    --> Click on Start Recording button.

    --> It will display MM01 screen….type the appropriate

    information in it.

    --> Type the Material no as : 4567E (Any no, But there should b 1 Character in it)

    --> Type Checmical Industry in INDUSTRY SECTOR

    --> Type COUPONS in MATERIAL TYPE

    --> Now click on Select Views button.

    --> Select BASIC DATA 1

    --> Click on Ok button

    --> Under Basic data tab under Material, it will display the Material number.

    --> Type the short description and “Provide EA as Base Unit Of Measure”

    --> CLICK ON BACK AND IT WILL ASK U TO SAVE THE DATA, CLICK ON YES

    --> Again click on Back, it will ask if u wish to save the changes to record entries.

    -> Click on Yes

    --> Now, u will be in Initial screen

    --> Select the record and Click on Program button

    --> Now, provide any program name

    --> Now, select ‘Transfer from recording’

    --> Click on Tick mark

    --> Give some short description

    --> Type as Executable

    --> Click on Source Code button

    --> Automatically the code will appear in SE 38 program.

    U can try these steps with any T-code by knowing the Mandatory fields in it.

    ********************************************************

    Here is the sample code which I have done for MK01.

    &----


    *&

    &----


    &

    *& AUTHOR : Krishna Chaitanya

    *& TITLE : BDC FOR MK01

    *& DESCR : UPLOAD THE DATA THROUGH FLAT FILE

    *& TRANSPORT : DOLK901203

    *& VERSION : V1

    *& DATE : 17th , JAN , 2008

    &----


    &

    report Z24_BDC_MK01

    no standard page heading line-size 255.

    &----


    &

    *& DECLARATIONS OF STRUCTURE FOR MK01

    &----


    &

    __________________________________________

    **U can create ur own flat file with the same structure

    with tab' s Namratha

    KTOKK, NAME1,SORTL, PSTLZ, LAND1

    ***

    __________________________________________

    TYPES : BEGIN OF TY_MK01 ,

    KTOKK TYPE RF02K-KTOKK ,

    NAME1 TYPE LFA1-NAME1 ,

    SORTL TYPE LFA1-SORTL ,

    PSTLZ TYPE LFA1-PSTLZ ,

    LAND1 TYPE LFA1-LAND1 ,

    END OF TY_MK01 .

    &----


    &

    *& DECLARATION OF INTERNAL TABLE

    &----


    &

    DATA : T_MK01 TYPE STANDARD TABLE OF TY_MK01 INITIAL SIZE 0 ,

    T_BDCDATA TYPE STANDARD TABLE OF BDCDATA INITIAL SIZE 0 ,

    T_BDCMSGCOLL TYPE STANDARD TABLE OF BDCMSGCOLL INITIAL SIZE 0 ,

    T_ERROR TYPE STANDARD TABLE OF TY_MK01 INITIAL SIZE 0 ,

    &----


    &

    *& DECLARATION OF WORK AREA

    &----


    &

    W_MK01 TYPE TY_MK01 ,

    W_BDCDATA TYPE BDCDATA ,

    W_BDCMSGCOLL TYPE BDCMSGCOLL .

    &----


    &

    *& DECLARATION OF SELECTION SCREEN

    &----


    &

    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME .

    PARAMETERS : P_FILE TYPE FILENAME .

    SELECTION-SCREEN END OF BLOCK B1 .

    &----


    &

    *& DECLARATION OF START-OF-SELECTION

    &----


    &

    START-OF-SELECTION .

    PERFORM SUB_UPLOAD_DATA .

    PERFORM SUB_POPULATE_BDC .

    PERFORM SUB_ERROR_REC .

    *include bdcrecx1.

    &----


    *& Form SUB_UPLOAD_DATA

    &----


    • text

    ----


    form SUB_UPLOAD_DATA .

    DATA : L_FILE TYPE STRING .

    L_FILE = P_FILE .

    CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

    filename = L_FILE

    HAS_FIELD_SEPARATOR = 'X'

    tables

    data_tab = T_MK01 .

    endform. " SUB_UPLOAD_DATA

    &----


    *& Form SUB_POPULATE_BDC

    &----


    • text

    ----


    form SUB_POPULATE_BDC .

    LOOP AT T_MK01 INTO W_MK01 .

    DATA : L_MSG TYPE STRING .

    REFRESH T_BDCDATA .

    perform bdc_dynpro using 'SAPMF02K' '0107'.

    perform bdc_field using 'BDC_CURSOR'

    'RF02K-KTOKK'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_field using 'RF02K-KTOKK'

    W_MK01-KTOKK.

    perform bdc_dynpro using 'SAPMF02K' '0110'.

    perform bdc_field using 'BDC_CURSOR'

    'LFA1-LAND1'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_field using 'LFA1-NAME1'

    W_MK01-NAME1.

    perform bdc_field using 'LFA1-SORTL'

    W_MK01-SORTL.

    perform bdc_field using 'LFA1-PSTLZ'

    W_MK01-PSTLZ.

    perform bdc_field using 'LFA1-LAND1'

    W_MK01-LAND1.

    perform bdc_dynpro using 'SAPMF02K' '0120'.

    perform bdc_field using 'BDC_CURSOR'

    'LFA1-KUNNR'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_dynpro using 'SAPMF02K' '0130'.

    perform bdc_field using 'BDC_CURSOR'

    'RF02K-LIFNR'.

    perform bdc_field using 'BDC_OKCODE'

    '=ENTR'.

    perform bdc_dynpro using 'SAPLSPO1' '0300'.

    perform bdc_field using 'BDC_OKCODE'

    '=YES'.

    CALL TRANSACTION 'MK01' USING T_BDCDATA MODE 'N' MESSAGES INTO T_BDCMSGCOLL .

    IF SY-SUBRC <> 0 .

    APPEND W_MK01 TO T_ERROR .

    ENDIF .

    CLEAR W_BDCMSGCOLL .

    READ TABLE T_BDCMSGCOLL INTO W_BDCMSGCOLL INDEX 1 .

    CLEAR L_MSG .

    CALL FUNCTION 'FORMAT_MESSAGE'

    EXPORTING

    ID = W_BDCMSGCOLL-MSGID

    LANG = SY-LANGU

    NO = W_BDCMSGCOLL-MSGNR

    V1 = W_BDCMSGCOLL-MSGV1

    V2 = W_BDCMSGCOLL-MSGV2

    V3 = W_BDCMSGCOLL-MSGV3

    V4 = W_BDCMSGCOLL-MSGV4

    IMPORTING

    MSG = L_MSG

    EXCEPTIONS

    NOT_FOUND = 1

    OTHERS = 2

    .

    IF sy-subrc = 0.

    WRITE : / 'MESSAGE FOR ' , W_MK01-KTOKK ,'-------' , L_MSG .

    ENDIF.

    ENDLOOP .

    endform. " SUB_POPULATE_BDC

    ----


    • Start new screen *

    ----


    FORM BDC_DYNPRO USING PROGRAM DYNPRO.

    CLEAR W_BDCDATA.

    W_BDCDATA-PROGRAM = PROGRAM.

    W_BDCDATA-DYNPRO = DYNPRO.

    W_BDCDATA-DYNBEGIN = 'X'.

    APPEND W_BDCDATA TO T_BDCDATA .

    ENDFORM.

    ----


    • Insert field *

    ----


    FORM BDC_FIELD USING FNAM FVAL.

    CLEAR W_BDCDATA.

    W_BDCDATA-FNAM = FNAM.

    W_BDCDATA-FVAL = FVAL.

    APPEND W_BDCDATA TO T_BDCDATA .

    ENDFORM.

    &----


    *& Form SUB_ERROR_REC

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form SUB_ERROR_REC .

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    filename = 'C:/ERRORS OF MK01.TXT'

    WRITE_FIELD_SEPARATOR = 'X'

    tables

    data_tab = T_ERROR .

    endform. " SUB_ERROR_REC

    Hey Namratha...I know there will be little confusion. But, trust me...try with this code and u will automatically able to work with any Transcation code.

    All the best!

    Edited by: Krishna Chaitanya on Mar 21, 2008 9:41 AM

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hello Namratha,

      Sorry for the deyalyed response!

      I got VA01 program, He had used session method here to upload Header data and item data.

      I will provoide you flat file shortly for VA01 and alos for MK01 too....or u can do it ur self by recording madatory fields.

      Let me know if you are using call transcation/ Session method for VA01 to upload the data?

      ****************************

      Here is the code to upload the data using VA01- session method

      ****************************

      report ZBDC3_VA01

      no standard page heading line-size 255.

      include bdcrecx1.

      types : begin of ty_head,

      auart(4),

      vkorg(4),

      vtweg(2),

      spart(2),

      kunnr(10),

      bstkd(10),

      end of ty_head.

      types: begin of ty_item,

      matnr(18) type c,

      kwmeng(13) type c,

      end of ty_item.

      data: it_head type table of ty_head. " Header

      data: wa_head like line of it_head.

      data: it_item type table of ty_item. " Item

      data: wa_item like line of it_item.

      data:v_kwmeng(30) type c,

      v_mabnr(30) type c.

      DATA: VAL(2) TYPE N VALUE 01.

      DATA : w_file2 TYPE string,

      w_file1 TYPE string.

      PARAMETERS: filename LIKE rlgrap-filename.

      PARAMETERS: filenam1 LIKE rlgrap-filename.

      AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.

      CALL FUNCTION 'F4_FILENAME'

      IMPORTING

      file_name = filename.

      AT SELECTION-SCREEN ON VALUE-REQUEST FOR filenam1.

      CALL FUNCTION 'F4_FILENAME'

      IMPORTING

      file_name = filenam1.

      START-OF-SELECTION.

      w_file2 = filename.

      w_file1 = filenam1.

                                  • HEADER ************************

                                  CALL FUNCTION 'GUI_UPLOAD'

                                  EXPORTING

                                  filename = w_file2

                                  filetype = 'ASC'

                                  has_field_separator = 'X'

                                  TABLES

                                  data_tab = it_head.

                                                              • Item *******************

                                                              CALL FUNCTION 'GUI_UPLOAD'

                                                              EXPORTING

                                                              filename = w_file1

                                                              filetype = 'ASC'

                                                              has_field_separator = 'X'

                                                              TABLES

                                                              data_tab = it_item.

                                                              perform open_group.

                                                              loop at it_head into wa_head.

                                                              .

                                                              perform bdc_dynpro using 'SAPMV45A' '0101'.

                                                              perform bdc_field using 'BDC_CURSOR'

                                                              'VBAK-AUART'.

                                                              perform bdc_field using 'BDC_OKCODE'

                                                              '/00'.

                                                              perform bdc_field using 'VBAK-AUART'

                                                              WA_HEAD-AUART.

                                                              perform bdc_field using 'VBAK-VKORG'

                                                              WA_HEAD-VKORG.

                                                              perform bdc_field using 'VBAK-VTWEG'

                                                              WA_HEAD-VTWEG.

                                                              perform bdc_field using 'VBAK-SPART'

                                                              WA_HEAD-SPART.

                                                              perform bdc_dynpro using 'SAPMV45A' '4001'.

                                                              perform bdc_field using 'BDC_OKCODE'

                                                              '/00'.

                                                              perform bdc_field using 'VBKD-BSTKD'

                                                              WA_HEAD-BSTKD.

                                                              perform bdc_field using 'VBKD-BSTDK'

                                                              '30.01.2006'.

                                                              perform bdc_field using 'KUAGV-KUNNR'

                                                              WA_HEAD-KUNNR.

                                                              perform bdc_field using 'RV45A-KETDAT'

                                                              '30.01.2006'.

                                                              perform bdc_field using 'RV45A-KPRGBZ'

                                                              'D'.

                                                              .

                                                              perform bdc_field using 'VBKD-ZTERM'

                                                              '0001'.

                                                              perform bdc_field using 'VBKD-INCO1'

                                                              'CIF'.

                                                              perform bdc_field using 'VBKD-INCO2'

                                                              'COST INSUSRABCE FRIEGHT'.

                                                              loop at it_item into wa_item .

                                                              CONCATENATE 'RV45A-MABNR(' '0' VAL ')' INTO v_MABNR.

                                                              CONCATENATE 'RV45A-KWMENG(' '0' VAL ')' INTO v_kwmeng.

                                                              perform bdc_field using 'BDC_CURSOR'

                                                              v_kwmeng.

                                                              perform bdc_field using v_mabnr

                                                              wa_item-matnr.

                                                              perform bdc_field using v_kwmeng

                                                              wa_item-kwmeng.

                                                              perform bdc_dynpro using 'SAPMV45A' '4001'.

                                                              perform bdc_field using 'BDC_OKCODE'

                                                              '/00'.

                                                              VAL = VAL + 1.

                                                              IF VAL > 5.

                                                              VAL = 5.

                                                              ENDIF.

                                                              endloop.

                                                              VAL = 01.

                                                              perform bdc_dynpro using 'SAPMV45A' '4001'.

                                                              perform bdc_field using 'BDC_OKCODE'

                                                              '=SICH'.

                                                              perform bdc_transaction using 'VA01'.

                                                              endloop.

                                                              perform close_group.

                                                              ****************************************************************

                                                              *****************************************************************

                                                              Regards,

                                                              Krishna Chaitanya

                                                          Before answering

                                                          You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
                                                          You must be Logged in to submit an answer.

                                                          Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.