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

Conversion Issue

Hi Experts,

Iam new to conversion programs in SAP.

My Requirement: I will get one file from EBI from tht

i have to get the data n post it in BDC.

Iam new to BDC concepts also.

Could anybody suggest me with the sample

code n why we need to use BDC to

the data n explain me clearly.

Points will be rewarded fro helpful answer.

Regards

Ashok

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 22, 2008 at 02:02 PM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 22, 2008 at 02:14 PM

    For documentation: you can refer above links posted by Swati...

    For sample code: see the program below.... The below program uses both the methods(Call transaction and session method).

    Would be easier if you can let me know the transaction??

    ************************************************************************report ZSOU_PRA2

    no standard page heading line-size 255.

    tables : t100.

    data: bdctab like bdcdata occurs 0 with header line,

    msgtab like bdcmsgcoll occurs 0 with header line.

    data: g_counter type i.

    data: begin of errtab occurs 0,

    msgtype,

    index type i,

    message(100),

    end of errtab.

    *data : a(3) type c.

    *data decleration for excel sheet it.

    data : begin of it_data_excel occurs 0,

    material_code(18)," type c

    • material_description(100)," type c

    MRP_TYPE(2),

    RECORDER_POINT(17),

    • UOM(3),

    MRP_CONTROLLER(3),

    LOT_SIZE(2),

    MAXIMUM_STOCK_LEVEL(17),

    PROCUREMENT_TYPE(1),

    GR_PROCESSING_TIME(3),

    SAFETY_STOCK(17),

    SERVICE_LEVEL(3),

    AVAILABILITY_CHECK(2),

    end of it_data_excel.

    data: it_excel type alsmex_tabline occurs 0 with header line.

    selection-screen begin of block b1 with frame title text-001.

    parameter path like rlgrap-filename default 'c:\mm_test.xls'.

    selection-screen end of block b1.

    perform get_excel_data.

    perform BDC_OPEN_GROUP.

    loop at it_data_excel.

    perform BDC.

    ENDLOOP.

    perform BDC_CLOSE_GROUP.

    loop at msgtab.

    PERFORM GENERATE_MESSAGE.

    ENDLOOP.

    PERFORM DISPLAY_MESSAGE.

    &----


    *& Form get_excel_data

    &----


    form get_excel_data.

    call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'

    EXPORTING

    filename = path

    i_begin_col = 1

    i_begin_row = 1

    i_end_col = 11

    i_end_row = 1000

    TABLES

    intern = it_excel

    EXCEPTIONS

    inconsistent_parameters = 1

    upload_ole = 2

    others = 3.

    if sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    write 'PATH OF EXCEL FILE IS NOT CORRECT'.

    exit.

    endif.

    loop at it_excel .

    if it_excel-col = '0001'.

    it_data_excel-material_code = it_excel-value.

    endif.

    • if it_excel-col = '0002'.

    • it_data_excel-material_description = it_excel-value .

    • endif.

    if it_excel-col = '0002'.

    it_data_excel-MRP_TYPE = it_excel-value .

    endif.

    if it_excel-col = '0003'.

    it_data_excel-RECORDER_POINT = it_excel-value .

    endif.

    *if it_excel-col = '0004'.

    • it_data_excel-UOM = it_excel-value .

    • endif.

    if it_excel-col = '0004'.

    it_data_excel-MRP_CONTROLLER = it_excel-value .

    endif.

    if it_excel-col = '0005'.

    it_data_excel-LOT_SIZE = it_excel-value .

    endif.

    if it_excel-col = '0006'.

    it_data_excel-MAXIMUM_STOCK_LEVEL = it_excel-value .

    endif.

    if it_excel-col = '0007'.

    it_data_excel-PROCUREMENT_TYPE = it_excel-value .

    endif.

    if it_excel-col = '008'.

    it_data_excel-GR_PROCESSING_TIME = it_excel-value .

    endif.

    if it_excel-col = '009'.

    it_data_excel-SAFETY_STOCK = it_excel-value .

    endif.

    if it_excel-col = '0010'.

    it_data_excel-SERVICE_LEVEL = it_excel-value .

    endif.

    if it_excel-col = '0011'.

    it_data_excel-AVAILABILITY_CHECK = it_excel-value .

    endif.

    at end of row.

    append it_data_excel.

    clear it_data_excel.

    endat.

    clear it_excel.

    endloop.

    endform. " get_excel_data

    &----


    *& Form BDC_OPEN_GROUP

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form BDC_OPEN_GROUP.

    call function 'BDC_OPEN_GROUP'

    exporting

    client = sy-mandt

    • DEST = FILLER8

    group = 'Mat_Master'

    • HOLDDATE = FILLER8

    keep = 'X'

    user = sy-uname

    • RECORD = FILLER1

    • IMPORTING

    • QID =

    exceptions

    client_invalid = 1

    destination_invalid = 2

    group_invalid = 3

    group_is_locked = 4

    holddate_invalid = 5

    internal_error = 6

    queue_error = 7

    running = 8

    system_lock_error = 9

    user_invalid = 10

    others = 11

    .

    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. " BDC_OPEN_GROUP

    &----


    *& Form BDC

    &----


    form BDC.

    refresh bdctab.

    PERFORM GENERATE_BDCDATA USING:

    'X' 'SAPLMGMM' '0060',

    ' ' 'BDC_CURSOR' 'RMMG1-MATNR',

    ' ' 'BDC_OKCODE' '=AUSW',

    ' ' 'RMMG1-MATNR' it_data_excel-material_code,""""

    'X' 'SAPLMGMM' '0070',

    ' ' 'BDC_CURSOR' 'MSICHTAUSW-DYTXT(05)',

    ' ' 'BDC_OKCODE' '=SCHL',

    ' ' 'MSICHTAUSW-KZSEL(04)' 'X',

    ' ' 'MSICHTAUSW-KZSEL(05)' 'X',

    'X' 'SAPLMGMM' '0080',

    ' ' 'BDC_CURSOR' 'RMMG1-WERKS',

    ' ' 'BDC_OKCODE' '=ENTR',

    ' ' 'RMMG1-WERKS' 'PW1',

    'X' 'SAPLMGMM' '3006',

    ' ' 'BDC_OKCODE' '=NEBE',

    ****

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 1001SUB1',

    *' ' 'MAKT-MAKTX' it_data_excel-material_description , """""

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 2481SUB2',

    *' ' 'MARA-MEINS' it_data_excel-UOM,

    *' ' 'MARC-EKGRP' 'GSS',

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 2482SUB3',

    ' ' 'MARC-DISMM' it_data_excel-MRP_TYPE, """""''

    ' ' 'MARC-MINBE' it_data_excel-RECORDER_POINT,"""

    ' ' 'MARC-DISPO' it_data_excel-MRP_CONTROLLER,""""

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 2483SUB4',

    ' ' 'MARC-DISLS' it_data_excel-LOT_SIZE, """"

    ' ' 'MARC-MABST' it_data_excel-MAXIMUM_STOCK_LEVEL,

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 2487SUB5',

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 2484SUB6',

    ' ' 'MARC-BESKZ' it_data_excel-PROCUREMENT_TYPE,"""

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 2485SUB7',

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

    ' ' 'MARC-WEBAZ' it_data_excel-GR_PROCESSING_TIME,

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 2486SUB8',

    ' ' 'MARC-EISBE' it_data_excel-SAFETY_STOCK,"""'

    ' ' 'MARC-LGRAD' it_data_excel-SERVICE_LEVEL,""""'

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 2489SUB9',

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 2480SUB10',

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 2479SUB11',

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 0001SUB12',

    'X' 'SAPLMGMM' '3006',

    ' ' 'BDC_OKCODE' '/00',

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 1005SUB1',

    *' ' 'MAKT-MAKTX' it_data_excel-material_description,

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 2491SUB2',

    *' ' 'MARC-PERKZ' 'M',

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 2492SUB3',

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 2493SUB4',

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

    ' ' 'BDC_CURSOR' 'MARC-MTVFP',

    ' ' 'MARC-MTVFP' it_data_excel-AVAILABILITY_CHECK,"""

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 2494SUB5',

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 2495SUB6',

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 2496SUB7',

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 2497SUB8',

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 2488SUB9',

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 2498SUB10',

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 0001SUB11',

    ' ' 'BDC_SUBSCR' 'SAPLMGD1 0001SUB12',

    'X' 'SAPLSPO1' '0300',

    ' ' 'BDC_OKCODE' '=YES'.

    call transaction 'MM02' using bdctab mode 'N' messages into msgtab.

    *WAIT UP TO 5 SECONDS.

    if sy-subrc <> 0.

    perform bdc_insert.

    ENDIF.

    endform. " BDC

    &----


    *& Form GENERATE_BDCDATA

    &----


    FORM GENERATE_BDCDATA USING VALUE(P_DYNBEGIN)

    VALUE(P_FNAM)

    VALUE(P_FVAL).

    IF P_DYNBEGIN = 'X'.

    BDCTAB-DYNBEGIN = 'X'.

    BDCTAB-PROGRAM = P_FNAM.

    BDCTAB-DYNPRO = P_FVAL.

    ELSE.

    BDCTAB-FNAM = P_FNAM.

    BDCTAB-FVAL = P_FVAL.

    ENDIF.

    APPEND BDCTAB.

    CLEAR BDCTAB.

    ENDFORM. " generate_bdcdata

    &----


    *& Form bdc_insert

    &----


    form bdc_insert.

    call function 'BDC_INSERT'

    exporting

    tcode = 'MM02'

    • POST_LOCAL = NOVBLOCAL

    • PRINTING = NOPRINT

    tables

    dynprotab = bdctab

    exceptions

    internal_error = 1

    not_open = 2

    queue_error = 3

    tcode_invalid = 4

    printing_invalid = 5

    posting_invalid = 6

    others = 7

    .

    if sy-subrc <> 0.

    exit.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    endif.

    endform. " bdc_insert

    &----


    *& Form BDC_CLOSE_GROUP

    &----


    form BDC_CLOSE_GROUP.

    call function 'BDC_CLOSE_GROUP'

    EXCEPTIONS

    not_open = 1

    queue_error = 2

    others = 3.

    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. " BDC_CLOSE_GROUP

    &----


    *& Form GENERATE_MESSAGE

    &----


    form GENERATE_MESSAGE.

    data: op(273), "100

    l_cnt_txt(6).

    select single * from t100 where sprsl = 'E' and

    arbgb = msgtab-msgid and msgnr = msgtab-msgnr.

    op = t100-text.

    if not msgtab-msgv1 is initial.

    condense msgtab-msgv1.

    replace '&' with msgtab-msgv1 into op .

    endif.

    if not msgtab-msgv2 is initial.

    condense msgtab-msgv2.

    replace '&' with msgtab-msgv2 into op .

    endif.

    if not msgtab-msgv3 is initial.

    condense msgtab-msgv3.

    replace '&' with msgtab-msgv3 into op .

    endif.

    if not msgtab-msgv4 is initial.

    condense msgtab-msgv4.

    replace '&' with msgtab-msgv4 into op .

    endif.

    g_counter = g_counter + 1.

    l_cnt_txt = g_counter.

    concatenate '(' l_cnt_txt ') ' op into op.

    condense op.

    errtab-msgtype = msgtab-msgtyp.

    errtab-message = op.

    append errtab.

    • perform display_message.

    endform. " DISPLAY_MESSAGE

    &----


    *& Form DISPLAY_MESSAGE

    &----


    form DISPLAY_MESSAGE.

    write :/ 'Processing completed. Check SM35 for Error Sessions'.

    loop at errtab where msgtype <> 'W' and msgtype <> 'S' and

    msgtype <> 'I'.

    if errtab-msgtype = 'W'.

    format color 6 intensified off.

    elseif errtab-msgtype = 'E'.

    format color 6 intensified on.

    elseif errtab-msgtype = 'S'.

    format color col_positive intensified off.

    elseif errtab-msgtype = 'A'.

    format color col_total intensified off.

    endif.

    • if errtab-slabno <> ' '.

    • write :/ errtab-slabno,errtab-aufnr,errtab-message.

    • else.

    • write :/ errtab-coilno,errtab-aufnr,errtab-message.

    • endif.

    write :/ errtab-message.

    format color off.

    endloop.

    endform. " DISPLAY_MESSAGE

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 22, 2008 at 02:19 PM

    Hi,

    Check this

    http://www.sap-img.com/ab001.htm

    Sample code

    REPORT zmmat_mast

    NO STANDARD PAGE HEADING LINE-SIZE 200.

    -


    TABLES :mara, marc.

    -


    INTERNAL TABLES *

    -


    DATA: BEGIN OF bdcdata OCCURS 0.

    INCLUDE STRUCTURE bdcdata.

    DATA: END OF bdcdata.

    DATA:BEGIN OF itab_basic OCCURS 0,

    matnr LIKE mara-matnr,

    zzmatnr LIKE mara-matnr,

    END OF itab_basic.

    DATA:BEGIN OF itab_mrp OCCURS 0,

    matnr LIKE mara-matnr,

    werks LIKE marc-werks,

    zzgpind LIKE marc-zzgpind,

    zzdate(10) type C ,

    END OF itab_mrp.

    DATA: BEGIN OF tab_mara OCCURS 0.

    INCLUDE STRUCTURE mara.

    DATA: END OF tab_mara.

    DATA: BEGIN OF tab_marc OCCURS 0.

    INCLUDE STRUCTURE marc.

    DATA: END OF tab_marc.

    DATA: ertab_basic LIKE itab_basic OCCURS 0 WITH HEADER LINE.

    DATA: ertab_mrp LIKE itab_mrp OCCURS 0 WITH HEADER LINE.

    DATA : v_ctr TYPE i VALUE 1. "Ctr for no orecords

    DATA : v_group(12) . "BDC Group Name

    DATA : v_group_ctr(3) TYPE n . "BDC Group Counter

    DATA : v_no_lines TYPE i.

    DATA: v_grpname(10) TYPE c.

    SELECTION-SCREEN BEGIN OF BLOCK dt-entry

    WITH FRAME TITLE text-002.

    selection-screen begin of line .

    selection-screen comment 01(49) text-101.

    parameters : p_basic radiobutton group r1.

    selection-screen end of line.

    selection-screen begin of line .

    selection-screen comment 01(49) text-102.

    parameters : p_mrp2 radiobutton group r1.

    selection-screen end of line.

    *

    *PARAMETERS :

    p_basic RADIOBUTTON GROUP r1,

    p_mrp2 RADIOBUTTON GROUP r1.

    SELECTION-SCREEN END OF BLOCK dt-entry.

    SELECTION-SCREEN SKIP 1.

    SELECTION-SCREEN BEGIN OF BLOCK fl-info

    WITH FRAME TITLE text-003.

    PARAMETER : p_dlhead AS CHECKBOX . "DEFAULT 'X'.

    SELECTION-SCREEN END OF BLOCK fl-info.

    *

    SELECTION-SCREEN SKIP 1.

    PARAMETER : p_max TYPE i DEFAULT '5000' . "No of rec / session

    SET PF-STATUS 'UPLOAD'.

    AT USER-COMMAND .

    IF sy-ucomm = 'UPLOAD' .

    IF p_basic = 'X'.

    IF NOT itab_basic[] IS INITIAL .

    PERFORM bdc_upload_basic.

    ENDIF.

    WRITE:/10 'Please execute the session in SM35 to Upload the data'.

    FORMAT INTENSIFIED OFF COLOR OFF .

    REFRESH itab_basic . CLEAR itab_basic .

    SET PF-STATUS space.

    ENDIF.

    IF p_mrp2 = 'X'.

    IF NOT itab_mrp[] IS INITIAL .

    PERFORM bdc_upload_mrp.

    ENDIF..

    WRITE:/10 'Please execute the session in SM35 to Upload the data'.

    REFRESH itab_mrp . CLEAR itab_mrp .

    SET PF-STATUS space.

    ENDIF.

    ENDIF.

    START-OF-SELECTION.

    IF p_basic = 'X'.

    CALL FUNCTION 'UPLOAD'

    EXPORTING

    CODEPAGE = ' '

    filename = 'C:\mm02_basic.txt '

    filetype = 'DAT'

    TABLES

    data_tab = itab_basic.

    IF p_dlhead EQ 'X'.

    READ TABLE itab_basic INDEX 1.

    DELETE itab_basic INDEX 1.

    CLEAR itab_basic.

    ENDIF.

    PERFORM blank_data_validation.

    ENDIF.

    IF p_mrp2 = 'X'.

    v_grpname = 'MRP2'.

    CALL FUNCTION 'UPLOAD'

    EXPORTING

    CODEPAGE = ' '

    filename = 'C:\mm02_mrp.txt '

    filetype = 'DAT'

    TABLES

    data_tab = itab_mrp.

    IF p_dlhead EQ 'X'.

    READ TABLE itab_mrp INDEX 1.

    DELETE itab_mrp INDEX 1.

    CLEAR itab_mrp.

    ENDIF.

    PERFORM valid_plant_check.

    ENDIF.

    IF sy-subrc 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    PERFORM display_data.

    END-OF-SELECTION.

    *----


    *

    Start new screen

    *

    *----


    *

    FORM bdc_dynpro USING program dynpro.

    CLEAR bdcdata.

    bdcdata-program = program.

    bdcdata-dynpro = dynpro.

    bdcdata-dynbegin = 'X'.

    APPEND bdcdata.

    ENDFORM.

    *----


    *

    Insert field

    *

    *----


    *

    FORM bdc_field USING fnam fval.

    CLEAR bdcdata.

    bdcdata-fnam = fnam.

    bdcdata-fval = fval.

    APPEND bdcdata.

    ENDFORM.

    &----


    *& Form blank_data_validation

    &----


    text

    -


    --> p1 text

    <-- p2 text

    -


    FORM blank_data_validation.

    LOOP AT itab_basic.

    IF itab_basic-matnr IS INITIAL OR itab_basic-zzmatnr IS INITIAL.

    MOVE-CORRESPONDING itab_basic TO ertab_basic .

    APPEND ertab_basic . CLEAR ertab_basic .

    DELETE itab_basic.

    CLEAR itab_basic.

    CONTINUE.

    ENDIF.

    SELECT SINGLE * INTO tab_mara FROM mara WHERE matnr = itab_basic-matnr

    .

    IF sy-subrc <> 0.

    MOVE-CORRESPONDING itab_basic TO ertab_basic .

    APPEND ertab_basic . CLEAR ertab_basic .

    DELETE itab_basic.

    CLEAR itab_basic.

    CONTINUE.

    ENDIF.

    *

    ENDLOOP.

    ENDFORM. " dt_qty_validation

    &----


    *& Form CALL_BDC_CLOSE_GROUP

    &----


    text

    -


    --> p1 text

    <-- p2 text

    -


    FORM call_bdc_close_group.

    CALL FUNCTION 'BDC_CLOSE_GROUP'

    EXCEPTIONS

    not_open = 1

    queue_error = 2.

    IF sy-subrc NE 0.

    WRITE: /5 'BDC CLOSE GROUP FAILED, return code = ', sy-subrc.

    EXIT.

    ENDIF.

    ENDFORM. " CALL_BDC_CLOSE_GROUP

    &----


    *& Form CALL_BDC_INSERT

    &----


    text

    -


    -->P_0545 text

    -


    FORM call_bdc_insert USING v_tran_code.

    DATA: xmode VALUE 'E'.

    CALL FUNCTION 'BDC_INSERT'

    EXPORTING

    tcode = v_tran_code

    TABLES

    dynprotab = bdcdata

    EXCEPTIONS

    internal_error = 1

    not_open = 2

    queue_error = 3.

    IF sy-subrc NE 0.

    WRITE: /5 'BDC insert GROUP FAILED, return code = ', sy-subrc.

    EXIT.

    ENDIF.

    ENDFORM. " CALL_BDC_INSERT

    &----


    *& Form display_data

    &----


    text

    -


    --> p1 text

    <-- p2 text

    -


    FORM display_data.

    WRITE:/ 'Press','''Upload''',

    'to create session with the following records'.

    IF p_basic = 'X'.

    PERFORM display_header.

    FORMAT COLOR 2.

    LOOP AT itab_basic.

    WRITE :/2 itab_basic-matnr,'|',

    23 itab_basic-zzmatnr,

    54 '|'.

    ENDIF.

    ENDLOOP.

    NEW-LINE.

    ULINE (54).

    ENDIF.

    IF p_mrp2 = 'X'.

    PERFORM display_header_mrp.

    FORMAT COLOR 2.

    LOOP AT itab_mrp.

    WRITE :/2 itab_mrp-matnr,'|',

    23 itab_mrp-werks,

    33 '|',

    37 itab_mrp-zzgpind,

    49 '|',

    52 itab_mrp-ZZDATE,

    65 '|'.

    ENDLOOP.

    NEW-LINE.

    ULINE (65).

    FORMAT COLOR OFF.

    SKIP 4.

    WRITE :/ 'Records with Errors will not be Included in Session' .

    PERFORM display_header_mrp.

    FORMAT COLOR 2.

    LOOP AT ertab_mrp.

    IF NOT ertab_mrp IS INITIAL OR NOT ertab_mrp-matnr IS INITIAL.

    WRITE :/2 ertab_mrp-matnr ,'|',

    23 ertab_mrp-werks,

    33 '|',

    37 ertab_mrp-zzgpind,

    49 '|' ,

    52 ertab_mrp-zzdate,

    65 '|'.

    ENDIF.

    ENDLOOP.

    NEW-LINE.

    ULINE (65).

    ENDIF.

    FORMAT COLOR OFF.

    ENDFORM. " display_data

    &----


    *& Form BDC_UPLOAD_basic

    &----


    text

    -


    --> p1 text

    <-- p2 text

    -


    FORM bdc_upload_basic.

    *CLEAR itab_basic. REFRESH itab_basic.

    CLEAR : v_ctr , v_no_lines .

    IF NOT itab_basic[] IS INITIAL .

    v_group_ctr = '1' .

    CONCATENATE 'BASIC_' v_group_ctr INTO v_group .

    PERFORM open_group USING v_group .

    LOOP AT itab_basic .

    IF v_ctr GE p_max .

    PERFORM call_bdc_close_group .

    v_group_ctr = v_group_ctr + 1 .

    CLEAR v_group .

    CONCATENATE 'BASIC_' v_group_ctr INTO v_group .

    PERFORM open_group USING v_group .

    v_ctr = 0 .

    ENDIF.

    PERFORM bdc_dynpro USING 'SAPLMGMM' '0060'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'RMMG1-MATNR'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '/00'.

    PERFORM bdc_field USING 'RMMG1-MATNR'

    itab_basic-matnr.

    'DEEPAKTESTMAT'.

    PERFORM bdc_dynpro USING 'SAPLMGMM' '0070'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'MSICHTAUSW-DYTXT(01)'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=ENTR'.

    PERFORM bdc_field USING 'MSICHTAUSW-KZSEL(01)'

    'X'.

    PERFORM bdc_dynpro USING 'SAPLMGMM' '4004'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=BU'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'MARA-ZZMATNR'.

    PERFORM bdc_field USING 'MARA-ZZMATNR'

    itab_basic-zzmatnr.

    'ADV#AM29F010-70JI'.

    PERFORM call_bdc_insert USING 'MM02'.

    CLEAR bdcdata . REFRESH bdcdata .

    v_no_lines = v_no_lines + 1 .

    v_ctr = v_ctr + 1.

    ENDLOOP.

    PERFORM call_bdc_close_group.

    SKIP 10.

    WRITE :/10 'Session by name BASIC* created' .

    WRITE :/10 'Total No of records uploaded - ' , v_no_lines .

    ENDIF.

    ENDFORM. " BDC_UPLOAD

    &----


    *& Form display_header

    &----


    text

    -


    --> p1 text

    <-- p2 text

    -


    FORM display_header.

    NEW-LINE.

    set left scroll-boundary column 48.

    FORMAT COLOR 1 INTENSIFIED ON.

    ULINE (54).

    WRITE :/' Avnet Material',

    21'|' ,

    23 'Green Product '

    , 54 '|'.

    NEW-LINE.

    ULINE (54).

    FORMAT COLOR OFF INTENSIFIED OFF.

    ENDFORM.

    &----


    *& Form bdc_upload_mrp

    &----


    text

    -


    --> p1 text

    <-- p2 text

    -


    FORM bdc_upload_mrp.

    PERFORM call_bdc_open_group2.

    CLEAR : v_ctr , v_no_lines .

    IF NOT itab_mrp[] IS INITIAL .

    v_group_ctr = '1' .

    CONCATENATE 'MRP_' v_group_ctr INTO v_group .

    PERFORM open_group USING v_group .

    LOOP AT itab_mrp .

    IF v_ctr GE p_max .

    PERFORM call_bdc_close_group .

    v_group_ctr = v_group_ctr + 1 .

    CLEAR v_group .

    CONCATENATE 'MRP2_' v_group_ctr INTO v_group .

    PERFORM open_group USING v_group .

    v_ctr = 0 .

    ENDIF.

    PERFORM bdc_dynpro USING 'SAPLMGMM' '0060'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'RMMG1-MATNR'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '/00'.

    PERFORM bdc_field USING 'RMMG1-MATNR'

    itab_mrp-matnr.

    'DEEPAKTESTMAT'.

    PERFORM bdc_dynpro USING 'SAPLMGMM' '0070'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'MSICHTAUSW-DYTXT(13)'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=ENTR'.

    PERFORM bdc_field USING 'MSICHTAUSW-KZSEL(13)'

    'X'.

    PERFORM bdc_dynpro USING 'SAPLMGMM' '0080'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'RMMG1-WERKS'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=ENTR'.

    PERFORM bdc_field USING 'RMMG1-WERKS'

    itab_mrp-werks.

    'sg11'.

    PERFORM bdc_dynpro USING 'SAPLMGMM' '4000'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '/00'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'MARC-ZZGPIND'.

    PERFORM bdc_field USING 'MARC-ZZGPIND'

    itab_mrp-zzgpind.

    'G'.

    PERFORM bdc_field USING 'BDC_CURSOR'

    'MARC-ZZDATE'.

    PERFORM bdc_field USING 'MARC-ZZDATE'

    itab_mrp-zzdate.

    'G'.

    PERFORM bdc_dynpro USING 'SAPLSPO1' '0300'.

    PERFORM bdc_field USING 'BDC_OKCODE'

    '=YES'.

    PERFORM call_bdc_insert USING 'MM02'.

    CLEAR bdcdata . REFRESH bdcdata .

    v_no_lines = v_no_lines + 1 .

    v_ctr = v_ctr + 1.

    ENDLOOP.

    PERFORM call_bdc_close_group.

    SKIP 10.

    WRITE :/10 'Session by name MRP2* created' .

    WRITE :/10 'Total No of records uploaded - ' , v_no_lines .

    ENDIF.

    ENDFORM. " bdc_upload_mrp

    &----


    *& Form display_header_mrp

    &----


    text

    -


    --> p1 text

    <-- p2 text

    -


    FORM display_header_mrp.

    NEW-LINE.

    set left scroll-boundary column 48.

    FORMAT COLOR 1 INTENSIFIED ON.

    ULINE (65).

    WRITE :/' Avnet Material',

    21'|' ,

    23 'Plant ' ,

    33 '|',

    35 'Indicator',

    49 '|',

    52 'Date',

    65 '|' .

    NEW-LINE.

    ULINE (65).

    FORMAT COLOR OFF INTENSIFIED OFF.

    ENDFORM. " display_header_mrp

    &----


    *& Form valid_plant_check

    &----


    text

    -


    --> p1 text

    <-- p2 text

    -


    FORM valid_plant_check.

    LOOP AT itab_mrp.

    IF itab_mrp-matnr IS INITIAL OR itab_mrp-werks IS INITIAL OR

    itab_mrp-zzgpind IS INITIAL.

    MOVE-CORRESPONDING itab_mrp TO ertab_mrp .

    APPEND ertab_mrp . CLEAR ertab_mrp .

    DELETE itab_mrp.

    CLEAR itab_mrp.

    CONTINUE.

    ENDIF.

    SELECT SINGLE * INTO tab_marc FROM marc WHERE matnr = tab_marc-matnr

    AND werks = itab_mrp-werks . .

    IF sy-subrc = 0.

    MOVE-CORRESPONDING itab_mrp TO ertab_mrp .

    APPEND ertab_mrp . CLEAR ertab_mrp .

    DELETE itab_mrp.

    CLEAR itab_mrp.

    CONTINUE.

    ENDIF.

    ENDLOOP.

    ENDFORM. " valid_plant_check

    -


    FORM open_group *

    -


    ........ *

    -


    FORM open_group USING p_grp .

    open batchinput group

    CALL FUNCTION 'BDC_OPEN_GROUP'

    EXPORTING

    client = sy-mandt

    group = p_grp

    user = sy-uname

    keep = 'X'.

    ENDFORM.

    Regards,

    Satish

    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.