Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SD: can't create SD contract using BAPI_CONTRACT_CREATEFROMDATA

Former Member
0 Likes
1,557

Hi,

my report is used for automatic generation of SD contracts from XLS file. <br>

The problem is that when I fill cond_value in condition table, BAPI gives me error V0(104) - Requested function ENT1 is not defined.<br>

Here is the example of my code for filling BAPI tables:<br>

<br>
DATA: ls_header           TYPE bapisdhd1 ,<br>
        ls_header_x         TYPE bapisdhd1x,<br>
        l_error(1) ,<br>
        l_percentage        TYPE i ,<br>
        l_text(150) ,<br>
        ls_vbep             TYPE vbep ,<br>
        lt_vbep             TYPE STANDARD TABLE OF vbep ,<br>
        l_lines             TYPE i ,<br>
        lt_return           TYPE bapiret2_t ,<br>
        lt_items            TYPE TABLE OF bapisditm,<br>
        lt_items_x          TYPE TABLE OF bapisditmx,<br>
        lt_partners         TYPE TABLE OF bapiparnr,<br>
        lt_conds            TYPE TABLE OF bapicond,<br>
        lt_conds_x            TYPE TABLE OF bapicondx,<br>
        lv_salesdocument    TYPE vbeln_va.<br><br>


  FIELD-SYMBOLS: <ls_imp_table> LIKE LINE OF gt_imp_table ,<br>
                 <ls_return>    TYPE bapiret2 ,<br>
                 <fs_partners>  TYPE bapiparnr,<br>
                 <fs_conds>     TYPE bapicond,<br>
                 <fs_conds_x>   TYPE bapicondx,<br>
                 <fs_items>     TYPE bapisditm,<br>
                 <fs_items_x>   TYPE bapisditmx.<br><br>


  LOOP AT gt_imp_table ASSIGNING <ls_imp_table> .<br>
    CLEAR: l_error ,<br>
           lt_vbep[] ,<br>
           lt_vbep ,<br>
           ls_vbep ,<br>
           ls_header,<br>
           ls_header_x,<br>
           lt_return ,<br>
           lt_return[],<br>
           lt_items[],<br>
           lt_items_x[],<br>
           lt_partners[],<br>
           lt_conds[],<br>
           lt_conds_x[],<br>
           lv_salesdocument.<br><br>

** Header<br>
    ls_header_x-updateflag = 'I'.<br>
    ls_header-doc_type    = <ls_imp_table>-auart.<br>
    ls_header_x-doc_type = 'X'.<br>
    IF <ls_imp_table>-bstkd IS NOT INITIAL.<br>
      ls_header-purch_no_c  = <ls_imp_table>-bstkd.<br>
      ls_header_x-purch_no_c = 'X'.<br>
    ENDIF.<br>

    IF <ls_imp_table>-vbegdat IS NOT INITIAL.<br>
      ls_header-ct_valid_f  = <ls_imp_table>-vbegdat.<br>
      ls_header_x-ct_valid_f = 'X'.<br>
    ENDIF.<br>
    IF <ls_imp_table>-venddat IS NOT INITIAL.<br>
      ls_header-ct_valid_t  = <ls_imp_table>-venddat.<br>
      ls_header_x-ct_valid_t = 'X'.<br><br>

    ENDIF.<br>
    ls_header-sales_org   = <ls_imp_table>-vkorg.<br>
    ls_header_x-sales_org = 'X'.<br>
    ls_header-distr_chan  = <ls_imp_table>-vtweg.<br>
    ls_header_x-distr_chan = 'X'.<br>
    ls_header_x-division = 'X'.<br>
    ls_header-division    = <ls_imp_table>-spart.<br>
    IF <ls_imp_table>-audat IS NOT INITIAL.<br>
      ls_header-price_date = <ls_imp_table>-audat.<br>
    ELSE.<br>
      ls_header-price_date = sy-datum.<br>
    ENDIF.<br>
    ls_header_x-price_date = 'X'.<br>
    ls_header-incoterms1 = 'EXW'.<br>
    ls_header_x-incoterms1 = 'X'.<br>
    ls_header-incoterms2 = 'BA'.<br>
    ls_header_x-incoterms2 = 'X'.<br>
    ls_header-pmnttrms = <ls_imp_table>-zterm.<br>
    ls_header_x-pmnttrms = 'X'.<br>
    ls_header-currency = 'EUR'.<br>
    ls_header_x-currency = 'X'.<br>
    IF <ls_imp_table>-vkbur IS NOT INITIAL.<br>
      ls_header-sales_off = <ls_imp_table>-vkbur.<br>
      ls_header_x-sales_off = 'X'.<br>
    ENDIF.<br><br><br><br>



** Items<br>
    APPEND INITIAL LINE TO lt_items ASSIGNING <fs_items> .<br>
    APPEND INITIAL LINE TO lt_items_x ASSIGNING <fs_items_x> .<br>
    <fs_items>-material = <ls_imp_table>-matnr.<br>
    <fs_items_x>-material = 'X'.<br>
    <fs_items_x>-updateflag = 'I'.<br>
    <fs_items>-plant = '1001'.<br>
    <fs_items_x>-plant = 'X'<br>
    <fs_items>-target_qty = '1.000'.<br>
    <fs_items_x>-target_qty = 'X'.<br>
    <fs_items>-itm_number = '000010'.<br>
    <fs_items_x>-itm_number = '000010'.<br>
    <fs_items>-purch_no_c = <ls_imp_table>-bstkd_p.<br>
    <fs_items_x>-purch_no_c = 'X'.<br>
    IF <ls_imp_table>-ps_psp_pnr IS NOT INITIAL.<br>
      <fs_items>-wbs_elem = <ls_imp_table>-ps_psp_pnr.<br>
      <fs_items>-wbs_elem = 'X'.<br>
    ENDIF.<br>
*    <fs_items>-mat_pr_grp = '10'.<br>
*    <fs_items_x>-mat_pr_grp = 'X'.<br>
    IF <ls_imp_table>-arktx IS NOT INITIAL.<br>
      <fs_items>-short_text = <ls_imp_table>-arktx.<br>
      <fs_items>-short_text = 'X'.<br>
    ENDIF.

    IF <ls_imp_table>-aufnr IS NOT INITIAL.<br>
      <fs_items>-orderid = <ls_imp_table>-aufnr.<br>
      <fs_items_x>-orderid = 'X'.<br>
    ENDIF.<br><br><br>


** Conditions<br>
    APPEND INITIAL LINE TO lt_conds ASSIGNING <fs_conds> .<br>
    APPEND INITIAL LINE TO lt_conds_x ASSIGNING <fs_conds_x> .<br>
    <fs_conds>-cond_type =  'PR00'.<br>
    <fs_conds_x>-cond_type =  'PR00'.<br>
*    <fs_conds_x>-updateflag = 'I'.<br>
    <fs_conds>-cond_value = <ls_imp_table>-netwr.<br>
    <fs_conds_x>-cond_value = 'X'.<br>
    <fs_conds>-currency = 'EUR'.<br>
    <fs_conds_x>-currency = 'X'.<br>
    <fs_conds>-itm_number = '000010'.<br>
    <fs_conds_x>-itm_number = '000010'.<br><br><br>


** Partner<br>

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'<br>
      EXPORTING<br>
        input  = <ls_imp_table>-kunnr<br>
      IMPORTING<br>
        output = <ls_imp_table>-kunnr.<br><br>

    APPEND INITIAL LINE TO lt_partners ASSIGNING <fs_partners>.<br>
    <fs_partners>-partn_role = 'AG'.<br>
    <fs_partners>-partn_numb = <ls_imp_table>-kunnr.<br><br>

    APPEND INITIAL LINE TO lt_partners ASSIGNING <fs_partners>.<br>
    <fs_partners>-partn_role = 'RE'.<br>
    <fs_partners>-partn_numb = <ls_imp_table>-kunnr.<br><br>

    APPEND INITIAL LINE TO lt_partners ASSIGNING <fs_partners>.<br>
    <fs_partners>-partn_role = 'RG'.<br>
    <fs_partners>-partn_numb = <ls_imp_table>-kunnr.<br><br>

    APPEND INITIAL LINE TO lt_partners ASSIGNING <fs_partners>.<br>
    <fs_partners>-partn_role = 'WE'.<br>
    <fs_partners>-partn_numb = <ls_imp_table>-kunnr.<br><br><br>


    CALL FUNCTION 'BAPI_CONTRACT_CREATEFROMDATA'<br>
      EXPORTING<br>
*   SALESDOCUMENTIN               =<br>
        contract_header_in            = ls_header<br>
   contract_header_inx           = ls_header_x<br>
*   SENDER                        =<br>
*   BINARY_RELATIONSHIPTYPE       = ' '<br>
*   INT_NUMBER_ASSIGNMENT         = ' '<br>
*   BEHAVE_WHEN_ERROR             = ' '<br>
*   LOGIC_SWITCH                  =<br>
*   TESTRUN                       =<br>
       convert                       = 'X'<br>
 IMPORTING<br>
   salesdocument                 = lv_salesdocument<br>
      TABLES<br>
   return                        = lt_return<br>
   contract_items_in             = lt_items<br>
*   CONTRACT_ITEMS_INX            =<br>
   contract_partners             = lt_partners<br>
   contract_conditions_in        = lt_conds<br>
              .

Could you pls help me with this problem?

Thanks

Juraj

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,033

Hi Juraj,

as Martin wrote, check OSS note 1301880. Or maybe your problem is that there is a missing entry in table T185F. Are You able to create contract manually? If You will put a break-point on a subroutine T185F_LESEN in include LV00FF0T and run BAPI again, You will see which entry is expected in the table, but not found. If OSS note will not help, You can probably correct it using transaction VFBS.

Regards,

Adrian

5 REPLIES 5
Read only

mvoros
Active Contributor
0 Likes
1,033

Hi,

have a look at note 1301880. I know ti's related to BAPI_SALESORDER_CHANGE but both BAPIs are using same core functionality. Have you also searched for another OSS notes? You can always debug your BAPI to figure out why it's failing. This might be painful but with debugger it's not that bad. You can [use a really nice transaction SE30|/people/olga.dolinskaja/blog/2009/12/11/abap-runtime-analysis-se30--how-to-analyze-abap-program-flow].

Good luck

Read only

Former Member
0 Likes
1,034

Hi Juraj,

as Martin wrote, check OSS note 1301880. Or maybe your problem is that there is a missing entry in table T185F. Are You able to create contract manually? If You will put a break-point on a subroutine T185F_LESEN in include LV00FF0T and run BAPI again, You will see which entry is expected in the table, but not found. If OSS note will not help, You can probably correct it using transaction VFBS.

Regards,

Adrian

Read only

0 Likes
1,033

Hi, I have checked that note but it is just for change of SD Doc.

I can create contract manually, but when I used that FM and fill cond_value in conditions, always this error appears.

I also tried to change T185F table, but it just raise another error in table T185V ( V0 - 102 ).

I have debugged the program and FM about 4 hours yesterday, but it doesn't help.

Do you have another suggestion?

thanks

Juraj

Read only

0 Likes
1,033

Hi,

there are around 100 notes related to the message V0(104). If you are sure that none of them are related to you and you are still unsuccessful with your debugging (SE30 is a really nice tool and you should see the place where you are getting your message) then I would open a ticket with SAP support.

Cheers

Read only

0 Likes
1,033

Hi, <br>

I found it. The problem was in accounting of the commitment.<br>

I saw this error when I set up contract manually but I was still able to save the contract.<br>

Thanks to all for your advice.<br>

Juraj