Application Development 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: 

reg:bapi_salesorder_createfromdat2

Former Member
0 Kudos

Hi ,

I had used the FM BAPI_SALESORDER_CREATEFROMDAT2 for sales order creation.

in condition structure BAPICOND iam passing a value 999.46 to COND_VALUE

before passing it to COND_VALUE iam dividing it by 10.but it is creating a sales order in which i found the rate as 999.5.i.e it is rounded .could any one help me out in passing the value without rounding .

Thanks & Regards,

Satish.

2 REPLIES 2

Former Member
0 Kudos

Hi

see the doc of the fun module

FU BAPI_SALESORDER_CREATEFROMDAT2

Sales order: Create Sales Order

Functionality

You can use this method to create sales orders.

You must enter at least sales order header data (via ORDER_HEADER_IN structure) and partner data (via the ORDER_PARTNERS table) as input parameters.

Enter the item data via the ORDER_ITEMS_IN table. You can allocate item numbers manually, by filling in the relevant fields, or the system does it, according to the settings for Customizing, by leaving the relevant fields blank.

If you have configurable items, you must enter the configuration data in the ORDER_CFGS_REF, ORDER_CFGS_INST, ORDER_CFGS_PART_OF and ORDER_CFGS_VALUE tables.

Credit cards can be transferred via the BAPICCARD structure, on the one hand, data for card identification, on the other, data for a transaction which has taken place in an external system.

Once you have created the sales order successfully, you will receive the document number (SALESDOCUMENT field). Any errors that may occur will be announced via the RETURN parameter.

If no sales area has been created in the sales order header, then the system creates the sales area from the sold-to party or ship-to party, who has been entered in the partner table. If a clear sales area cannot be created, you will receive a system message, and the sales order will not be created.

Notes

1. Mandatory entries:

ORDER_HEADER_IN : DOC_TYPE Sales document type

SALES_ORG Sales organization

DISTR_CHAN Distribution channel

DIVISION Division

ORDER_PARTNERS..: PARTN_ROLE Partner role, SP sold-to party

PARTN_NUMB Customer number

ORDER_ITEMS_IN..: MATERIAL Material number

2. Ship-to party:

If no ship-to party is entered, use the following: Ship-to party =

sold-to party.

3. Commit control:

The BAPI does not have a database commit. This means that the relevant application must leave the commit, in order that can be carried out on on the database. The BAPI BAPI_TRANSACTION_COMMIT is available for this.

4. German key words:

The following key words must be entered in German, independantly of

the logon language:

DOC_TYPE Sales document type, for example: TA for standard order

PARTN_ROLE Partner role, for example: WE for ship-to party

Further information

You can find further information in the OSS. The note 93091 contains general information on the BAPIs in SD.

Parameters

SALESDOCUMENTIN

ORDER_HEADER_IN

ORDER_HEADER_INX

SENDER

BINARY_RELATIONSHIPTYPE

INT_NUMBER_ASSIGNMENT

BEHAVE_WHEN_ERROR

LOGIC_SWITCH

TESTRUN

CONVERT

SALESDOCUMENT

RETURN

ORDER_ITEMS_IN

ORDER_ITEMS_INX

ORDER_PARTNERS

ORDER_SCHEDULES_IN

ORDER_SCHEDULES_INX

ORDER_CONDITIONS_IN

ORDER_CONDITIONS_INX

ORDER_CFGS_REF

ORDER_CFGS_INST

ORDER_CFGS_PART_OF

ORDER_CFGS_VALUE

ORDER_CFGS_BLOB

ORDER_CFGS_VK

ORDER_CFGS_REFINST

ORDER_CCARD

ORDER_TEXT

ORDER_KEYS

EXTENSIONIN

PARTNERADDRESSES

Exceptions

Sample code:

************SALES ORDER INPUT CREATION.

PARAMETERS: p_auart TYPE auart OBLIGATORY.

PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.

PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.

PARAMETERS: p_spart TYPE vtweg OBLIGATORY.

PARAMETERS: p_sold TYPE kunnr OBLIGATORY.

PARAMETERS: p_ship TYPE kunnr OBLIGATORY.

*ITEM

PARAMETERS: p_matnr TYPE matnr OBLIGATORY.

PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.

PARAMETERS: p_plant TYPE werks_d OBLIGATORY.

PARAMETERS: p_itcat TYPE pstyv OBLIGATORY.

  • DATA DECLARATIONS.

DATA: v_vbeln LIKE vbak-vbeln.

DATA: header LIKE bapisdhead1.

DATA: headerx LIKE bapisdhead1x.

DATA: item LIKE bapisditem OCCURS 0 WITH HEADER LINE.

DATA: itemx LIKE bapisditemx OCCURS 0 WITH HEADER LINE.

DATA: partner LIKE bapipartnr OCCURS 0 WITH HEADER LINE.

DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

DATA: lt_schedules_inx TYPE STANDARD TABLE OF bapischdlx

WITH HEADER LINE.

DATA: lt_schedules_in TYPE STANDARD TABLE OF bapischdl

WITH HEADER LINE.

  • HEADER DATA

header-doc_type = p_auart.

headerx-doc_type = 'X'.

header-sales_org = p_vkorg.

headerx-sales_org = 'X'.

header-distr_chan = p_vtweg.

headerx-distr_chan = 'X'.

header-division = p_spart.

headerx-division = 'X'.

headerx-updateflag = 'I'.

  • PARTNER DATA

partner-partn_role = 'AG'.

partner-partn_numb = p_sold.

APPEND partner.

partner-partn_role = 'WE'.

partner-partn_numb = p_ship.

APPEND partner.

  • ITEM DATA

itemx-updateflag = 'I'.

item-itm_number = '000010'.

itemx-itm_number = 'X'.

item-material = p_matnr.

itemx-material = 'X'.

item-plant = p_plant.

itemx-plant = 'X'.

item-target_qty = p_menge.

itemx-target_qty = 'X'.

item-target_qu = 'EA'.

itemx-target_qu = 'X'.

item-item_categ = p_itcat.

itemx-item_categ = 'X'.

APPEND item.

APPEND itemx.

  • Fill schedule lines

lt_schedules_in-itm_number = '000010'.

lt_schedules_in-sched_line = '0001'.

lt_schedules_in-req_qty = p_menge.

APPEND lt_schedules_in.

  • Fill schedule line flags

lt_schedules_inx-itm_number = '000010'.

lt_schedules_inx-sched_line = '0001'.

lt_schedules_inx-updateflag = 'X'.

lt_schedules_inx-req_qty = 'X'.

APPEND lt_schedules_inx.

  • Call the BAPI

CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'

EXPORTING

sales_header_in = header

sales_header_inx = headerx

IMPORTING

salesdocument_ex = v_vbeln

TABLES

return = return

sales_items_in = item

sales_items_inx = itemx

sales_schedules_in = lt_schedules_in

sales_schedules_inx = lt_schedules_inx

sales_partners = partner.

  • Check the return table.

LOOP AT return WHERE type = 'E' OR type = 'A'.

EXIT.

ENDLOOP.

IF sy-subrc = 0.

WRITE: / 'Error in creating document'.

ELSE.

COMMIT WORK AND WAIT.

WRITE: / 'Document ', v_vbeln, ' created'.

ENDIF.

Reward points if useful

Regards

Anji

Former Member
0 Kudos

Hi ,

just now i debugged and seen the bapi BAPI_SALESORDER_CREATEFROMDAT2 ....

in the include program LVBAK001 which calls your BAPI .... here only you amount is converted and PASSED to BAPICOND-COND_VALUE ....

i have give you the code ..... so please go through there in debug mode .... because i don't have your test data .....

i think you should not divide it by 10 ..... becuse see the below if logic .... if you are not understanding then go through the include LVBAK001 program ... keep break point and run the BAPI .....

even you can also see it

  IF DA_KONV-KRECH CA 'AHI'. "percentage --> division by 10.
        CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_EXTERN_9'
             EXPORTING
                  CURRENCY        = '3'
                  AMOUNT_INTERNAL = DA_KONV-KBETR
             IMPORTING
                  AMOUNT_EXTERNAL = CH_BAPICOND-COND_VALUE.
      ELSE.
        CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_EXTERN_9'
             EXPORTING
                  CURRENCY        = DA_KONV-WAERS
                  AMOUNT_INTERNAL = DA_KONV-KBETR
             IMPORTING
                  AMOUNT_EXTERNAL = CH_BAPICOND-COND_VALUE.
      ENDIF.
    ENDIF.

Reward points if it is usefull .....

gIRISH