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

Table Control in BDC

Hai Experts,

i have problem with table control in bdc, can any tell me wat exact code for table control in bdc,n plz give flat file for this prm or any related

HANDLING TABLE CONTROL IN BDC

DATA : BEGIN OF IT_DUMMY OCCURS 0,

DUMMY(100) TYPE C,

END OF IT_DUMMY.

DATA : BEGIN OF IT_XK01 OCCURS 0,

LIFNR(10) TYPE C,

BUKRS(4) TYPE C,

EKORG(4) TYPE C,

KTOKK(4) TYPE C,

NAME1(30) TYPE C,

SORTL(10) TYPE C,

LAND1(3) TYPE C,

SPRAS(2) TYPE C,

AKONT(6) TYPE C,

FDGRV(2) TYPE C,

WAERS(3) TYPE C,

END OF IT_XK01,

BEGIN OF IT_BANK OCCURS 0,

BANKS(3) TYPE C,

BANKL(10) TYPE C,

BANKN(10) TYPE C,

KOINH(30) TYPE C,

LIFNR(10) TYPE C,

END OF IT_BANK.

DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,

IT_BDCMSGCOLL LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = 'C:\VENDOR.TXT'

FILETYPE = 'ASC'

TABLES

DATA_TAB = IT_DUMMY.

LOOP AT IT_DUMMY.

IF IT_DUMMY-DUMMY+0(2) = '11'.

IT_XK01-LIFNR = IT_DUMMY-DUMMY+2(10).

IT_XK01-BUKRS = IT_DUMMY-DUMMY+12(4).

IT_XK01-EKORG = IT_DUMMY-DUMMY+16(4).

IT_XK01-KTOKK = IT_DUMMY-DUMMY+20(4).

IT_XK01-NAME1 = IT_DUMMY-DUMMY+24(30).

IT_XK01-SORTL = IT_DUMMY-DUMMY+54(10).

IT_XK01-LAND1 = IT_DUMMY-DUMMY+64(3).

IT_XK01-SPRAS = IT_DUMMY-DUMMY+67(2).

IT_XK01-AKONT = IT_DUMMY-DUMMY+69(6).

IT_XK01-FDGRV = IT_DUMMY-DUMMY+75(2).

IT_XK01-WAERS = IT_DUMMY-DUMMY+77(3).

APPEND IT_XK01.

ELSE.

IT_BANK-BANKS = IT_DUMMY-DUMMY+2(3).

IT_BANK-BANKL = IT_DUMMY-DUMMY+5(10).

IT_BANK-BANKN = IT_DUMMY-DUMMY+15(10).

IT_BANK-KOINH = IT_DUMMY-DUMMY+25(30).

IT_BANK-LIFNR = IT_DUMMY-DUMMY+55(10).

APPEND IT_BANK.

ENDIF.

ENDLOOP.

LOOP AT IT_XK01.

REFRESH IT_BDCDATA.

perform bdc_dynpro using 'SAPMF02K' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RF02K-REF_LIFNR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RF02K-LIFNR'

IT_XK01-LIFNR.

perform bdc_field using 'RF02K-BUKRS'

IT_XK01-BUKRS.

perform bdc_field using 'RF02K-EKORG'

IT_XK01-EKORG.

perform bdc_field using 'RF02K-KTOKK'

IT_XK01-KTOKK.

perform bdc_dynpro using 'SAPMF02K' '0110'.

perform bdc_field using 'BDC_CURSOR'

'LFA1-TELX1'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'LFA1-NAME1'

IT_XK01-NAME1.

perform bdc_field using 'LFA1-SORTL'

IT_XK01-SORTL.

perform bdc_field using 'LFA1-LAND1'

IT_XK01-LAND1.

perform bdc_field using 'LFA1-SPRAS'

IT_XK01-SPRAS.

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'

'LFBK-KOINH(02)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

DATA : FNAM(20) TYPE C,

IDX TYPE C.

MOVE 1 TO IDX.

LOOP AT IT_BANK WHERE LIFNR = IT_XK01-LIFNR.

CONCATENATE 'LFBK-BANKS(' IDX ')' INTO FNAM.

perform bdc_field using FNAM

IT_BANK-BANKS.

CONCATENATE 'LFBK-BANKL(' IDX ')' INTO FNAM.

perform bdc_field using FNAM

IT_BANK-BANKL.

CONCATENATE 'LFBK-BANKN(' IDX ')' INTO FNAM.

perform bdc_field using FNAM

IT_BANK-BANKN.

CONCATENATE 'LFBK-KOINH(' IDX ')' INTO FNAM.

perform bdc_field using FNAM

IT_BANK-KOINH.

IDX = IDX + 1.

ENDLOOP.

perform bdc_dynpro using 'SAPMF02K' '0130'.

perform bdc_field using 'BDC_CURSOR'

'LFBK-BANKS(01)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_dynpro using 'SAPMF02K' '0210'.

perform bdc_field using 'BDC_CURSOR'

'LFB1-FDGRV'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'LFB1-AKONT'

IT_XK01-AKONT.

perform bdc_field using 'LFB1-FDGRV'

IT_XK01-FDGRV.

perform bdc_dynpro using 'SAPMF02K' '0215'.

perform bdc_field using 'BDC_CURSOR'

'LFB1-ZTERM'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPMF02K' '0220'.

perform bdc_field using 'BDC_CURSOR'

'LFB5-MAHNA'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPMF02K' '0310'.

perform bdc_field using 'BDC_CURSOR'

'LFM1-WAERS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'LFM1-WAERS'

IT_XK01-WAERS.

perform bdc_dynpro using 'SAPMF02K' '0320'.

perform bdc_field using 'BDC_CURSOR'

'WYT3-PARVW(01)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_dynpro using 'SAPLSPO1' '0300'.

perform bdc_field using 'BDC_OKCODE'

'=YES'.

CALL TRANSACTION 'XK01' USING IT_BDCDATA

MODE 'A'

UPDATE 'S'

MESSAGES INTO IT_BDCMSGCOLL.

ENDLOOP.

FORM BDC_DYNPRO USING PROG SCR.

CLEAR IT_BDCDATA.

IT_BDCDATA-PROGRAM = PROG.

IT_BDCDATA-DYNPRO = SCR.

IT_BDCDATA-DYNBEGIN = 'X'.

APPEND IT_BDCDATA.

ENDFORM.

FORM BDC_FIELD USING FNAM FVAL.

CLEAR IT_BDCDATA.

IT_BDCDATA-FNAM = FNAM.

IT_BDCDATA-FVAL = FVAL.

APPEND IT_BDCDATA.

ENDFORM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2008 at 04:15 AM

    hi Rajesh,

    I am sending the code for the XK01 Transcation, about how to handle the table control

    which i have created in my organisation, check this code thorougly,

    i have used all mandatory fields, so it might not be a problem for u to create flat file .

    if helpful Reward me points.

    REPORT ZNSK_TABLE_CONTROL

    NO STANDARD PAGE HEADING LINE-SIZE 255.

    &----


    *& Structure Declarations

    &----


    • Structure declaration for Header STRUCTURE

    TYPES: BEGIN OF TY_HEADER,

    LIFNR TYPE LIF16,

    BUKRS TYPE BUKRS,

    EKORG TYPE EKORG,

    KTOKK TYPE KTOKK,

    ANRED TYPE ANRED,

    NAME1 TYPE NAME1_GP,

    SORTL TYPE SORTL,

    LAND1 TYPE LAND1_GP,

    AKONT TYPE AKONT,

    FDGRV TYPE FDGRV,

    WAERS TYPE BSTWA,

    END OF TY_HEADER,

    • STRUCTURE DECLARATION FOR ITEM STRUCTURE

    BEGIN OF TY_ITEM,

    LIFNR TYPE LIF16,

    BANKS TYPE BANKS,

    BANKL TYPE BANKK,

    BANKN TYPE BANKN,

    KOINH TYPE KOINH_FI,

    END OF TY_ITEM,

    • STRUCTURE DECLARATION FOR SOURCE STRUCTURE

    BEGIN OF TY_UPLOAD,

    F1 TYPE CHAR16,

    F2 TYPE CHAR4,

    F3 TYPE CHAR15,

    F4(18) TYPE C,

    F5(60) TYPE C,

    F6 TYPE CHAR35,

    F7 TYPE CHAR10,

    F8 TYPE CHAR3,

    F9 TYPE CHAR10,

    F10 TYPE CHAR10,

    F11 TYPE CHAR13,

    END OF TY_UPLOAD.

    &----


    *& Internal table Declarations

    &----


    • INTERNAL TABLE FOR TY_UPLOAD

    DATA: T_UPLOAD TYPE STANDARD TABLE OF TY_UPLOAD INITIAL SIZE 0,

    • INTENAL TABLE FOR TY_HEADER

    T_HEADER TYPE STANDARD TABLE OF TY_HEADER INITIAL SIZE 0,

    • INTERNAL TABLE FOR TY_ITEM

    T_ITEM TYPE STANDARD TABLE OF TY_ITEM INITIAL SIZE 0,

    • INTERNAL TABLE FOR BDCDATA

    T_BDCDATA TYPE STANDARD TABLE OF BDCDATA INITIAL SIZE 0,

    &----


    *& WORK AREA Declarations

    &----


    • WORK AREA FOR SOURCE STRUCTURE

    W_UPLOAD TYPE TY_UPLOAD,

    • WORK AREA FOR HEADER STRUCTURE

    W_HEADER TYPE TY_HEADER,

    • WORK AREA FOR ITEM STRUCTURE

    W_ITEM TYPE TY_ITEM,

    • WORK AREA FOR BDCDATA.

    W_BDCDATA TYPE BDCDATA,

    • ADDITIONAL WORK AREA FOR UPLOAD STRUCTURE

    L_UPLOAD TYPE TY_UPLOAD.

    &----


    *& SELECTION-SCREEN Declarations

    &----


    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.

    PARAMETERS: P_FLNAME TYPE FILENAME.

    SELECTION-SCREEN END OF BLOCK B1.

    START-OF-SELECTION.

    • UPLOADING THE DATA

    PERFORM UPLOAD_DATA.

    • POPULATING THE BDCDATA TABLE

    PERFORM BDC_DATA.

    • INCLUDE BDCRECX1.

    START-OF-SELECTION.

    &----


    *& Form UPLOAD_DATA

    &----


    • text

    ----


    FORM UPLOAD_DATA .

    DATA: L_FLNAME TYPE STRING .

    L_FLNAME = P_FLNAME.

    CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

    FILENAME = L_FLNAME

    HAS_FIELD_SEPARATOR = 'X'

    TABLES

    DATA_TAB = T_UPLOAD.

    LOOP AT T_UPLOAD INTO L_UPLOAD.

    W_UPLOAD = L_UPLOAD.

    AT NEW F1.

    W_HEADER-LIFNR = W_UPLOAD-F1.

    W_HEADER-BUKRS = W_UPLOAD-F2.

    W_HEADER-EKORG = W_UPLOAD-F3.

    W_HEADER-KTOKK = W_UPLOAD-F4.

    W_HEADER-ANRED = W_UPLOAD-F5.

    W_HEADER-NAME1 = W_UPLOAD-F6.

    W_HEADER-SORTL = W_UPLOAD-F7.

    W_HEADER-LAND1 = W_UPLOAD-F8.

    W_HEADER-AKONT = W_UPLOAD-F9.

    W_HEADER-FDGRV = W_UPLOAD-F10.

    W_HEADER-WAERS = W_UPLOAD-F11.

    APPEND W_HEADER TO T_HEADER.

    CLEAR W_UPLOAD.

    CONTINUE.

    ENDAT.

    W_ITEM-LIFNR = W_UPLOAD-F1.

    W_ITEM-BANKS = W_UPLOAD-F2.

    W_ITEM-BANKL = W_UPLOAD-F3.

    W_ITEM-BANKN = W_UPLOAD-F4.

    W_ITEM-KOINH = W_UPLOAD-F5.

    APPEND W_ITEM TO T_ITEM.

    CLEAR W_ITEM.

    ENDLOOP.

    ENDFORM. " UPLOAD_DATA

    &----


    *& Form BDC_DATA

    &----


    • text

    ----


    FORM BDC_DATA .

    • HEADER SCREEN(1)

    • CLEAR W_HEADER.

    LOOP AT T_HEADER INTO W_HEADER.

    REFRESH T_BDCDATA.

    PERFORM BDC_DYNPRO USING 'SAPMF02K' '0100'.

    PERFORM BDC_FIELD USING 'BDC_CURSOR'

    'RF02K-EKORG'.

    PERFORM BDC_FIELD USING 'BDC_OKCODE'

    '/00'.

    • PERFORM BDC_FIELD USING 'RF02K-LIFNR'

    • W_HEADER-LIFNR.

    PERFORM BDC_FIELD USING 'RF02K-BUKRS'

    W_HEADER-BUKRS.

    PERFORM BDC_FIELD USING 'RF02K-EKORG'

    W_HEADER-EKORG.

    PERFORM BDC_FIELD USING 'RF02K-KTOKK'

    W_HEADER-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-ANRED'

    W_HEADER-ANRED.

    PERFORM BDC_FIELD USING 'LFA1-NAME1'

    W_HEADER-NAME1.

    PERFORM BDC_FIELD USING 'LFA1-SORTL'

    W_HEADER-SORTL.

    PERFORM BDC_FIELD USING 'LFA1-LAND1'

    W_HEADER-LAND1.

    PERFORM BDC_DYNPRO USING 'SAPMF02K' '0120'.

    PERFORM BDC_FIELD USING 'BDC_CURSOR'

    'LFA1-KUNNR'.

    PERFORM BDC_FIELD USING 'BDC_OKCODE'

    '/00'.

    • ITEM SCREEN

    DATA: N TYPE C.

    N = 1.

    • CLEAR W_ITEM.

    LOOP AT T_ITEM INTO W_ITEM WHERE LIFNR = W_HEADER-LIFNR.

    DATA: L_BANKS TYPE CHAR20,

    L_BANKL TYPE CHAR20,

    L_BANKN TYPE CHAR20,

    L_BANKK TYPE CHAR20.

    PERFORM BDC_DYNPRO USING 'SAPMF02K' '0130'.

    PERFORM BDC_FIELD USING 'BDC_CURSOR'

    'LFBK-KOINH(03)'.

    PERFORM BDC_FIELD USING 'BDC_OKCODE'

    '=ENTR'.

    CONCATENATE 'LFBK-BANKS' '(' '0' N ')' INTO L_BANKS.

    PERFORM BDC_FIELD USING L_BANKS

    W_ITEM-BANKS.

    CONCATENATE 'LFBK-BANKL' '(' '0' N ')' INTO L_BANKL.

    PERFORM BDC_FIELD USING L_BANKL

    W_ITEM-BANKL.

    CONCATENATE 'LFBK-BANKN' '(' '0' N ')' INTO L_BANKN.

    PERFORM BDC_FIELD USING L_BANKN

    W_ITEM-BANKN.

    CONCATENATE 'LFBK-KOINH' '(' '0' N ')' INTO L_BANKK.

    PERFORM BDC_FIELD USING L_BANKK

    W_ITEM-KOINH.

    N = N + 1.

    ENDLOOP.

    PERFORM BDC_DYNPRO USING 'SAPMF02K' '0130'.

    PERFORM BDC_FIELD USING 'BDC_CURSOR'

    'LFBK-BANKS(01)'.

    PERFORM BDC_FIELD USING 'BDC_OKCODE'

    '=ENTR'.

    • HEADER SCREEN(2).

    PERFORM BDC_DYNPRO USING 'SAPMF02K' '0210'.

    PERFORM BDC_FIELD USING 'BDC_CURSOR'

    'LFB1-FDGRV'.

    PERFORM BDC_FIELD USING 'BDC_OKCODE'

    '/00'.

    PERFORM BDC_FIELD USING 'LFB1-AKONT'

    W_HEADER-AKONT.

    PERFORM BDC_FIELD USING 'LFB1-FDGRV'

    W_HEADER-FDGRV.

    PERFORM BDC_DYNPRO USING 'SAPMF02K' '0215'.

    PERFORM BDC_FIELD USING 'BDC_CURSOR'

    'LFB1-ZTERM'.

    PERFORM BDC_FIELD USING 'BDC_OKCODE'

    '/00'.

    PERFORM BDC_DYNPRO USING 'SAPMF02K' '0220'.

    PERFORM BDC_FIELD USING 'BDC_CURSOR'

    'LFB5-MAHNA'.

    PERFORM BDC_FIELD USING 'BDC_OKCODE'

    '/00'.

    PERFORM BDC_DYNPRO USING 'SAPMF02K' '0310'.

    PERFORM BDC_FIELD USING 'BDC_CURSOR'

    'LFM1-WAERS'.

    PERFORM BDC_FIELD USING 'BDC_OKCODE'

    '/00'.

    PERFORM BDC_FIELD USING 'LFM1-WAERS'

    W_HEADER-WAERS.

    PERFORM BDC_DYNPRO USING 'SAPMF02K' '0320'.

    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 'XK01' USING T_BDCDATA MODE 'A'.

    ENDLOOP.

    ENDFORM. " BDC_DATA

    ----


    • 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. "BDC_DYNPRO

    ----


    • 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. "BDC_FIELD

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2008 at 09:53 PM

    seems to be every thing done correctly, but the data type for idx parameter is wrong.

    it should be idx(2) TYPE n.

    the standard prog. alwasy holds the screen fields like LFBK-BANKS(01), LFBK-BANKS(02) etc,

    not like LFBK-BANKS(1).

    just change the data type and lenght of it to 2.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2008 at 07:19 AM

    Hi Rajesh,

    I will send a sample code 4 ur problem check it once.And also i will attach a FLAT FILE at the end of program check it once.Plz copy the below code and execute it ok...

    &----


    *& Report YBDC_MB1C_HEADER_ITEM_CALLTRA *

    *& *

    &----


    *& DEVELOPER : KIRAN KUMAR.G *

    *& PURPOSE : UPLOAD DATA(T.CODE = MB1C) INTO DATABASE(CALL TRANS) *

    *& CREATION DT: 5/12/2007 *

    *& REQUEST : ERPK900035 *

    &----


    REPORT YBDC_MB1C_HEADER_ITEM_CALLTRA.

    ----


    • Global BDC And Message Structures

    ----


    DATA: gt_bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE,

    gt_msgtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.

    ----


    • Global Variables For File Path And Messages

    ----


    DATA: gv_infile TYPE string, "For Path Selection

    gv_msg TYPE string. "For Message Printing

    ----


    • For Elimination Of Illegal Screens

    ----


    DATA: opt TYPE ctu_params.

    ----


    • Global Variables

    ----


    DATA: gv_num(2) TYPE n,

    gv_matnr(20),

    gv_erfmg(20).

    gv_num = 1.

    ----


    • Internal Table

    ----


    DATA: BEGIN OF gt_data OCCURS 0,

    f1(20),

    f2(20),

    f3(20),

    f4(20),

    f5(20),

    f6(20),

    f7(20),

    f8(20),

    f9(20),

    END OF gt_data.

    ----


    • Selection Criteria

    ----


    SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

    PARAMETERS: p_file LIKE rlgrap-filename,

    p_mode.

    SELECTION-SCREEN : END OF BLOCK b1.

    ----


    • Selection Path

    ----


    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

    PERFORM selection_path.

    START-OF-SELECTION.

    opt-nobinpt = 'X'.

    opt-defsize = 'X'.

    opt-updmode = 'A'.

    ----


    • Upload the data

    ----


    PERFORM upload_data.

    END-OF-SELECTION.

    ----


    • Populate Data Into BDCDATA Structure

    ----


    PERFORM populate_data.

    &----


    *& Form selection_path

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM selection_path .

    CALL FUNCTION 'F4_FILENAME'

    EXPORTING

    program_name = syst-cprog

    dynpro_number = syst-dynnr

    • FIELD_NAME = ' '

    IMPORTING

    file_name = p_file.

    gv_infile = p_file.

    ENDFORM. " selection_path

    &----


    *& Form upload_data

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM upload_data .

    REFRESH : gt_data.

    CLEAR : gt_data.

    CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

    filename = gv_infile

    filetype = 'ASC'

    has_field_separator = 'X'

    • HEADER_LENGTH = 0

    • READ_BY_LINE = 'X'

    • DAT_MODE = ' '

    • IMPORTING

    • FILELENGTH =

    • HEADER =

    TABLES

    data_tab = gt_data

    EXCEPTIONS

    file_open_error = 1

    file_read_error = 2

    no_batch = 3

    gui_refuse_filetransfer = 4

    invalid_type = 5

    no_authority = 6

    unknown_error = 7

    bad_data_format = 8

    header_not_allowed = 9

    separator_not_allowed = 10

    header_too_long = 11

    unknown_dp_error = 12

    access_denied = 13

    dp_out_of_memory = 14

    disk_full = 15

    dp_timeout = 16

    OTHERS = 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.

    ENDFORM. " upload_data

    &----


    *& Form Populate_data

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM populate_data .

    LOOP AT gt_data.

    *Header Information

    IF gt_data-f1 = 'H'.

    PERFORM firstscreen.

    CLEAR gt_data.

    ENDIF.

    *Item Information

    IF gt_data-f1 = 'I'.

    PERFORM secondscreen.

    *Save data and call the Call Transaction Method

    AT END OF f1.

    PERFORM save.

    CALL TRANSACTION 'MB1C' USING gt_bdcdata MODE p_mode

    MESSAGES INTO gt_msgtab.

    PERFORM messages.

    REFRESH gt_bdcdata.

    CLEAR gv_num. "USED IN CONCATENATE STEP

    ENDAT.

    gv_num = gv_num + 1.

    ENDIF. "End of Item Data

    ENDLOOP.

    ENDFORM. " Populate_data

    &----


    *& Form firstscreen

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM firstscreen .

    PERFORM bdc_dynpro USING 'SAPMM07M' '0400'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'MKPF-BKTXT'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '/00'.

    PERFORM bdc_field USING 'MKPF-BLDAT'

    gt_data-f2.

    PERFORM bdc_field USING 'MKPF-BUDAT'

    gt_data-f3.

    PERFORM bdc_field USING 'MKPF-BKTXT'

    gt_data-f4.

    PERFORM bdc_field USING 'RM07M-BWARTWA'

    gt_data-f5.

    PERFORM bdc_field USING 'RM07M-WERKS'

    gt_data-f6.

    PERFORM bdc_field USING 'RM07M-LGORT'

    gt_data-f7.

    PERFORM bdc_field USING 'XFULL'

    'X'.

    PERFORM bdc_field USING 'RM07M-WVERS2'

    'X'.

    PERFORM bdc_dynpro USING 'SAPMM07M' '0421'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'MSEG-ERFMG(01)'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=BU'.

    ENDFORM. " firstscreen

    &----


    *& Form secondscreen

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM secondscreen .

    CONCATENATE 'MSEG-MATNR(' gv_num ')' INTO gv_matnr.

    CONCATENATE 'MSEG-ERFMG(' gv_num ')' INTO gv_erfmg.

    PERFORM bdc_field USING 'MSEGK-KUNNR'

    gt_data-f2.

    PERFORM bdc_field USING gv_matnr

    gt_data-f3.

    PERFORM bdc_field USING gv_erfmg

    gt_data-f4.

    PERFORM bdc_field USING 'DKACB-FMORE'

    'X'.

    ENDFORM. " secondscreen

    &----


    *& Form save

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM save .

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=BU'.

    ENDFORM. " save

    ----


    • Start new screen *

    ----


    FORM bdc_dynpro USING program dynpro.

    CLEAR gt_bdcdata.

    gt_bdcdata-program = program.

    gt_bdcdata-dynpro = dynpro.

    gt_bdcdata-dynbegin = 'X'.

    APPEND gt_bdcdata.

    ENDFORM. "BDC_DYNPRO

    ----


    • Insert field *

    ----


    FORM bdc_field USING fnam fval.

    CLEAR gt_bdcdata.

    gt_bdcdata-fnam = fnam.

    gt_bdcdata-fval = fval.

    APPEND gt_bdcdata.

    ENDFORM. "BDC_FIELD

    &----


    *& Form messages

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM messages .

    LOOP AT gt_msgtab.

    CALL FUNCTION 'FORMAT_MESSAGE'

    EXPORTING

    id = sy-msgid

    lang = sy-langu

    no = sy-msgno

    v1 = sy-msgv1

    v2 = sy-msgv2

    v3 = sy-msgv3

    v4 = sy-msgv4

    IMPORTING

    msg = gv_msg

    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-tabix EQ 1.

    WRITE:/ 'Process Log' COLOR 3.

    ENDIF.

    WRITE:/ gv_msg.

    ENDLOOP.

    REFRESH : gt_msgtab.

    CLEAR : gt_msgtab.

    ENDFORM. " messages

    ----


    • FLAT FILE

    ----


    *H 10012005 20022005 HEADER 451 1000 0001

    *I 1 100-300 5

    *I 1 100-400 3

    *I 1 100-100 12

    *H 12012005 12022005 HEADER 451 1000 0001

    *I 2 100-200 4

    ----


    ----


    • General Information(t.code= MB1C)

    ----


    *DOC DATE : 10.1.2005 POSTING DATE : 20.2.2005

    *HEADER TEXT : HEADER

    *MATERIAL TYPE :451 PLANT : 1000

    *STORAGE LOCATION : 0001

    *

    *CUSTOMER :1

    *MATERIAL NO : 100-300

    *QUANTITY : 5

    *BUSINESS AREA : 0001

    ----


    Award points if helpful

    Kiran Kumar.G.A

    Add a comment
    10|10000 characters needed characters exceeded

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.