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

BDC RECORDING

Hi,

I am designing a Technical Spec for BDC, Tcode VK11. But the Input file what i am getting is totally different from the mapping fields.For that first i created a internal table with the same structure like what i am getting the flat file. For the each input record we will create the following standard pricing conditions. ZCG2, ZCM3, ZCH2, ZCM3, ZCH3. The input record is having all the condition type values in a single record. But in mapping only one value for each pricing condition is there. Can u tell me how to do mapping from the Input file. If u can't understand this also try to give me an idea. If u are having any code or TD for simle BDC, Please send it to me...

Thanks......

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2007 at 11:56 AM

    Hi

    You have two ways to do this .

    1 .If your input file ZCG2, ZCM3, ZCH2, ZCM3, ZCH3 I mean separated by comma save as CSV(Comma Separated) so that you can upload as CSV declare ur internal table as one field type string.

    2 .Upload the data and internal table split based on comma.

    First let me know how will your input file look like.

    Please reward if useful.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2007 at 07:37 PM

    Hi,

    Try this code. Make some adjustments.

    REPORT ZSD_PRICING_CONDITION_ADK01.

    *-Internal Table Definition to load Pricing by Material

    DATA: BEGIN OF it_price_m OCCURS 10,

    kschl(4) TYPE c, "Condition Type

    vkorg(4) TYPE c, "Sales Organization

    vtweg(2) TYPE c, "Distribution Channel

    matnr(18) TYPE c, "Material

    kbetr(16) TYPE c, "Price

    END OF it_price_m.

    DATA: it_price_m_tmp LIKE it_price_m OCCURS 1 WITH HEADER LINE,

    it_pass_m like RV13A-kschl occurs 1 with header line,

    s_price_m LIKE it_price_m.

    DATA: BEGIN OF it_price_m_err OCCURS 10,

    kschl(4),

    message(255),

    END OF it_price_m_err.

    *-Internal Table Definition to load Pricing by Material/Customer

    DATA: BEGIN OF it_price_mc OCCURS 10,

    kschl(4) TYPE c, "Condition Type

    vkorg(4) TYPE c, "Sales Organization

    vtweg(2) TYPE c, "Distribution Channel

    kunnr(10) type c, "Customer

    matnr(18) TYPE c, "Material

    kbetr(16) TYPE c, "Price

    END OF it_price_mc.

    DATA: it_price_mc_tmp LIKE it_price_mc OCCURS 1 WITH HEADER LINE,

    s_price_mc LIKE it_price_mc.

    DATA: BEGIN OF it_price_mc_err OCCURS 10,

    kschl(4),

    kunnr(10),

    message(255),

    END OF it_price_mc_err.

    data: begin of it_pass_mc occurs 10,

    kschl(4),

    kunnr(10),

    end of it_pass_mc.

    DATA: g_tab_size LIKE sy-tabix,

    g_mode type c,

    bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE,

    it_msgs LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.

    SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-003.

    PARAMETERS: rb_m RADIOBUTTON GROUP rb1,

    rb_mc RADIOBUTTON GROUP rb1,

    p_file LIKE rlgrap-filename DEFAULT 'c:\systechi\aio\*.txt'.

    SELECTION-SCREEN ULINE.

    PARAMETERS: cb_fg as checkbox.

    SELECTION-SCREEN END OF BLOCK a1.

    *-Value request for file name

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

    PERFORM get_file_name CHANGING p_file.

    AT SELECTION-SCREEN.

    *-Read the upload input file

    if not rb_m is initial.

    CALL FUNCTION 'WS_UPLOAD'

    EXPORTING

    filename = p_file

    filetype = 'DAT'

    TABLES

    data_tab = it_price_m

    EXCEPTIONS

    OTHERS = 0.

    else.

    CALL FUNCTION 'WS_UPLOAD'

    EXPORTING

    filename = p_file

    filetype = 'DAT'

    TABLES

    data_tab = it_price_mc

    EXCEPTIONS

    OTHERS = 0.

    endif.

    START-OF-SELECTION.

    *-FOR TESTING PURPOSES ONLY. CAN BE REMOVED LATER IF NEEDED TO.

    *-Run the transaction in FOREGROUND/BACKGROUD depending on selection.

    if not cb_fg is initial.

    g_mode = 'A'.

    else.

    g_mode = 'N'.

    endif.

    *-Process kind of pricing load based on selection on sel-screen

    if not rb_m is initial.

    perform load_pricing_by_matnr.

    else.

    perform load_pricing_by_matnr_kunnr.

    endif.

    END-OF-SELECTION.

    *-Print summary depending upon what has been select on the sel-screen.

    if not rb_m is initial.

    perform print_summary_for_matnr.

    else.

    perform print_summary_for_matnr_kunnr.

    endif.

    &----


    *& Form GET_FILE_NAME

    &----


    FORM get_file_name CHANGING p_p_file.

    CALL FUNCTION 'F4_FILENAME'

    EXPORTING

    program_name = syst-cprog

    dynpro_number = syst-dynnr

    IMPORTING

    file_name = p_p_file.

    ENDFORM. " GET_FILE_NAME

    &----


    *& Form load_pricing_by_matnr

    &----


    form load_pricing_by_matnr.

    *-Loop through the price records which need to created.

    SORT it_price_m BY kschl vkorg vtweg.

    LOOP AT it_price_m.

    s_price_m = it_price_m.

    APPEND s_price_m TO it_price_m_tmp.

    *---Handle unique condition types as separate transactions.

    AT END OF vtweg.

    PERFORM create_pricing_by_matnr.

    REFRESH it_price_m_tmp. CLEAR it_price_m_tmp.

    ENDAT.

    ENDLOOP.

    endform. " load_pricing_by_material

    &----


    *& Form load_pricing_by_matnr_kunnr

    &----


    form load_pricing_by_matnr_kunnr.

    *-Loop through the price records which need to created.

    SORT it_price_mc BY kschl vkorg vtweg kunnr.

    LOOP AT it_price_mc.

    s_price_mc = it_price_mc.

    APPEND s_price_mc TO it_price_mc_tmp.

    *---Handle unique condition types as separate transactions.

    AT END OF kunnr.

    PERFORM create_pricing_by_matnr_kunnr.

    REFRESH it_price_mc_tmp. CLEAR it_price_mc_tmp.

    ENDAT.

    ENDLOOP.

    endform. " load_pricing_by_matnr_kunnr

    &----


    *& Form create_pricing_by_matnr

    &----


    FORM create_pricing_by_matnr.

    DATA: l_items(2) TYPE n VALUE 1,

    l_fname(14) type c.

    *-Read and load the BDC data for pricing's header information

    read table it_price_m_tmp index 1.

    PERFORM build_bdc_table USING: 'X' 'SAPMV13A' '0100',

    ' ' 'BDC_OKCODE' '/00',

    ' ' 'RV13A-KSCHL' it_price_m_tmp-kschl,

    'X' 'SAPLV14A' '0100',

    ' ' 'BDC_OKCODE' '=WEIT',

    ' ' 'RV130-SELKZ(03)' 'X',

    'X' 'SAPMV13A' '1304',

    ' ' 'BDC_OKCODE' '/00',

    ' ' 'KOMG-VKORG' it_price_m_tmp-vkorg,

    ' ' 'KOMG-VTWEG' it_price_m_tmp-vtweg.

    *-Loop through the internal table and load the material pricing data

    *-into the BDCDATA structure. Here we are filling 10 material per page

    *-in order to avoid the page down freaking problem in the BDCs.

    describe table it_price_m_tmp lines g_tab_size.

    LOOP AT it_price_m_tmp.

    concatenate 'KOMG-MATNR(' l_items ')' into l_fname.

    PERFORM build_bdc_table USING ' ' l_fname it_price_m_tmp-matnr.

    concatenate 'KONP-KBETR(' l_items ')' into l_fname.

    PERFORM build_bdc_table USING ' ' l_fname it_price_m_tmp-kbetr.

    add 1 to l_items.

    if l_items = 11 and l_items < g_tab_size.

    l_items = 2.

    PERFORM build_bdc_table USING: 'X' 'SAPMV13A' '1304',

    ' ' 'BDC_OKCODE' '=NEWP',

    'X' 'SAPMV13A' '1304',

    ' ' 'BDC_OKCODE' '/00'.

    elseif l_items <= g_tab_size.

    continue.

    else.

    exit.

    endif.

    endloop.

    PERFORM build_bdc_table USING: 'X' 'SAPMV13A' '1304',

    ' ' 'BDC_OKCODE' '=SICH'.

    *-Clear the messages table and call the transaction

    refresh it_msgs.

    CALL TRANSACTION 'VK11' using bdcdata

    mode g_mode

    update 'S'

    MESSAGES INTO it_msgs.

    *-Error handling for bdc's when call transaction fails

    if sy-subrc = 0.

    it_pass_m = it_price_m_tmp-kschl.

    append it_pass_m.

    else.

    READ TABLE it_msgs WITH KEY msgtyp = 'E'.

    MESSAGE ID it_msgs-msgid TYPE it_msgs-msgtyp NUMBER

    it_msgs-msgnr WITH it_msgs-msgv1 it_msgs-msgv2

    it_msgs-msgv3 it_msgs-msgv4 INTO it_price_m_err-message.

    it_price_m_err-kschl = it_price_m_tmp-kschl.

    APPEND it_price_m_err.

    endif.

    REFRESH BDCDATA.

    ENDFORM. " create_pricing_by_matnr

    &----


    *& Form create_pricing_by_matnr_kunnr

    &----


    form create_pricing_by_matnr_kunnr .

    DATA: l_items(2) TYPE n VALUE 1,

    l_fname(14) type c.

    *-Read and load the BDC data for pricing's header information

    read table it_price_mc_tmp index 1.

    PERFORM build_bdc_table USING:

    'X' 'SAPMV13A' '0100',

    ' ' 'BDC_OKCODE' '/00',

    ' ' 'RV13A-KSCHL' it_price_mc_tmp-kschl,

    'X' 'SAPLV14A' '0100',

    ' ' 'BDC_OKCODE' '=WEIT',

    ' ' 'RV130-SELKZ(01)' 'X',

    'X' 'SAPMV13A' '1305',

    ' ' 'BDC_OKCODE' '/00',

    ' ' 'KOMG-VKORG' it_price_mc_tmp-vkorg,

    ' ' 'KOMG-VTWEG' it_price_mc_tmp-vtweg,

    ' ' 'KOMG-KUNNR' it_price_mc_tmp-kunnr.

    *-Loop through the internal table and load the material pricing data

    *-into the BDCDATA structure. Here we are filling 10 material per page

    *-in order to avoid the page down freaking problem in the BDCs.

    describe table it_price_mc_tmp lines g_tab_size.

    LOOP AT it_price_mc_tmp.

    concatenate 'KOMG-MATNR(' l_items ')' into l_fname.

    PERFORM build_bdc_table USING ' ' l_fname it_price_mc_tmp-matnr.

    concatenate 'KONP-KBETR(' l_items ')' into l_fname.

    PERFORM build_bdc_table USING ' ' l_fname it_price_mc_tmp-kbetr.

    add 1 to l_items.

    if l_items = 11 and l_items < g_tab_size.

    l_items = 2.

    PERFORM build_bdc_table USING: 'X' 'SAPMV13A' '1305',

    ' ' 'BDC_OKCODE' '=NEWP',

    'X' 'SAPMV13A' '1305',

    ' ' 'BDC_OKCODE' '/00'.

    elseif l_items <= g_tab_size.

    continue.

    else.

    exit.

    endif.

    endloop.

    PERFORM build_bdc_table USING: 'X' 'SAPMV13A' '1305',

    ' ' 'BDC_OKCODE' '=SICH'.

    *-Clear the messages table and call the transaction

    refresh it_msgs.

    CALL TRANSACTION 'VK11' using bdcdata

    mode g_mode

    update 'S'

    MESSAGES INTO it_msgs.

    *-Error handling for bdc's when call transaction fails

    if sy-subrc = 0.

    it_pass_mc-kschl = it_price_mc_tmp-kschl.

    it_pass_mc-kunnr = it_price_mc_tmp-kunnr.

    append it_pass_mc.

    else.

    READ TABLE it_msgs WITH KEY msgtyp = 'E'.

    MESSAGE ID it_msgs-msgid TYPE it_msgs-msgtyp NUMBER

    it_msgs-msgnr WITH it_msgs-msgv1 it_msgs-msgv2

    it_msgs-msgv3 it_msgs-msgv4 INTO it_price_mc_err-message.

    it_price_mc_err-kschl = it_price_mc_tmp-kschl.

    it_price_mc_err-kunnr = it_price_mc_tmp-kunnr.

    APPEND it_price_mc_err.

    endif.

    REFRESH BDCDATA.

    endform. " create_pricing_by_matnr_kunnr

    &----


    *& Form build_bdc_table

    &----


    FORM build_bdc_table USING p_newdyn p_field p_value.

    CLEAR bdcdata.

    IF p_newdyn = 'X'.

    bdcdata-dynbegin = 'X'.

    bdcdata-program = p_field.

    bdcdata-dynpro = p_value.

    ELSE.

    bdcdata-fnam = p_field.

    bdcdata-fval = p_value.

    ENDIF.

    APPEND bdcdata.

    ENDFORM. "build_bdc_table

    &----


    *& Form print_summary_for_matnr

    &----


    form print_summary_for_matnr .

    *-Print the pricing condition types which were successfully loaded.

    loop at it_pass_m.

    at first.

    write:/1 text-m01.

    endat.

    write:/1 it_pass_m.

    endloop.

    *-Print the pricing condition types which errored out due to bad file.

    skip 2.

    loop at it_price_m_err.

    at first.

    write:/1 text-m02.

    endat.

    write:/1 it_price_m_err-kschl, 6 it_price_m_err-message.

    endloop.

    endform. " print_summary_for_matnr

    &----


    *& Form print_summary_for_matnr_kunnr

    &----


    form print_summary_for_matnr_kunnr .

    *-Print the pricing condition types which were successfully loaded.

    loop at it_pass_mc.

    at first.

    write:/1 text-m01.

    endat.

    write:/1 it_pass_mc-kschl, 6 it_pass_mc-kunnr.

    endloop.

    *-Print the pricing condition types which errored out due to bad file.

    skip 2.

    loop at it_price_mc_err.

    at first.

    write:/1 text-m02.

    endat.

    write:/1 it_price_mc_err-kschl,

    6 it_price_mc_err-kunnr,

    17 it_price_m_err-message.

    endloop.

    endform. " print_summary_for_matnr_kunnr

    Regards,

    Aman

    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.