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

Doubt in SD_SALESDOCUMENT_CREATE

Former Member
0 Likes
1,134

Hi Abapers,

I am using this FM 'SD_SALESDOCUMENT_CREATE' to create Credit Note.

I need your help to understand this FM.

I want to pass different parnter values for different line items.

For example if i have 2 line items. I need to pass partner values like WE(Ship-to-party Number) and RG(Payer Number) for Each item.

Line item table:

Posnr. Material

0010 123

0020 234

For the posnr 10 i have to pass value X as WE number and Y as RG Number.

Similarly for Posnr 20 I have to pass value A as WE number and B as RG Number.

Is it possible to achieve this using this FM.

If yes, how i can do this.

Thanks and Regards,

Mohanraj.N

6 REPLIES 6
Read only

Former Member
0 Likes
853

Hello Mohanraj!

You must add rows to the table parameter SALES_PARTNERS

For example :

SALES_PARTNERS-PARTN_ROLE = WE

SALES_PARTNERS-PARTN_NUMB = X

SALES_PARTNERS-ITM_NUMBER = 10

APPEND

SALES_PARTNERS-PARTN_ROLE = RG

SALES_PARTNERS-PARTN_NUMB = Y

SALES_PARTNERS-ITM_NUMBER = 10

APPEND

SALES_PARTNERS-PARTN_ROLE = WE

SALES_PARTNERS-PARTN_NUMB = A

SALES_PARTNERS-ITM_NUMBER = 20

APPEND

SALES_PARTNERS-PARTN_ROLE = RG

SALES_PARTNERS-PARTN_NUMB = B

SALES_PARTNERS-ITM_NUMBER = 20

APPEND

Best Regards.

Claudio (Aparatey)

Read only

0 Likes
853

Hi Claudio,

I used this way already, but the return table from the FM says an Error Message.

'Please Enter Sold-to-party and Ship-to-party'.

Thanks,

Mohanraj.N

Read only

0 Likes
853

Hi Claudio,

I got the solution, thanks for your Input.

We have to send partner details for POSNR 00 also for Header Sold-to-party and Ship-To-Party.

Thanks.

Read only

0 Likes
853

Hi Mohan,

PI am also getting the same error:

My code:

order_header_in-doc_type = 'Z023'.

order_header_in-sales_org = '1000'.

order_header_in-distr_chan = '01'.

order_header_inx-DOC_TYPE ='X'.

order_header_inx-SALES_ORG = 'X'.

order_header_inx-DISTR_CHAN = 'X'.

order_partners-partn_role = 'SH'.

order_partners-partn_numb = '0000040007'.

order_partners-ITM_NUMBER = '000000'.

APPEND order_partners.

order_partners-partn_role = 'SH'.

order_partners-partn_numb = '0000040007'.

order_partners-ITM_NUMBER = '000010'.

APPEND order_partners.

*order_partners-partn_role = 'ZS'.

*order_partners-partn_numb = '1046'.

*APPEND order_partners.

*

*

*IF ORDER_HEADER_IN-DOC_TYPE = 'Z023'.

*ORDER_PARTNERS-ITM_NUMBER = '10'.

*order_partners-partn_role = 'ZO'.

*order_partners-partn_numb = '0001000005'.

*APPEND order_partners.

*ENDIF.

      • add next line with more than one item

order_items_in-itm_number = '000010'.

order_items_in-material = '000000000021109916'.

order_items_in-target_qty = '1.000'.

order_items_in-plant = 'Z101'.

*order_items_in-target_qu = 'ST'.

*order_items_in-sales_unit = 'ST'.

APPEND order_items_in.

*order_schedules_in-req_qty = '1.000'.

*APPEND order_schedules_in.

*

*

**Add following lines with more than one line

itemx-itm_number = '000010'.

itemx-updateflag = 'X'.

itemx-plant = 'X'.

itemx-PO_ITM_NO = 'X'.

itemx-material = 'X'.

itemx-target_qty = 'X'.

append itemx.

*

*

*

*

*order_items_in-itm_number = '000020'.

*order_items_in-material = '000000000000111111'.

*order_items_in-target_qty = '1.000'.

*order_items_in-target_qu = 'ST'.

*order_items_in-sales_unit = 'ST'.

*APPEND order_items_in.

*order_schedules_in-req_qty = '1.000'.

*APPEND order_schedules_in.

*

*

*itemx-itm_number = '000020'.

*itemx-updateflag = 'I'.

*itemx-material = 'X'.

*itemx-target_qty = 'X'.

*append itemx.

*stop add more lines

sales_cond_in-ITM_NUMBER = '000010'.

sales_cond_in-COND_TYPE = 'EDI1'.

sales_cond_in-COND_VALUE = '10'.

sales_cond_in-CURRENCY = 'GBP'.

APPEND sales_cond_in.

sales_cond_inx-ITM_NUMBER ='000010'.

sales_cond_inx-COND_TYPE ='EDI1'.

sales_cond_inx-COND_VALUE ='X'.

sales_cond_inx-UPDATEFLAG ='X'.

sales_cond_inx-CURRENCY ='X'.

APPEND sales_cond_inx.

REFRESH return.

BREAK-POINT.

*

*CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'

*EXPORTING

*sales_header_in = order_header_in

*TABLES

*return = return

*sales_items_in = order_items_in

*sales_items_inx = itemx

*sales_partners = order_partners

*sales_schedules_in = order_schedules_in.

CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'

EXPORTING

SALES_HEADER_IN = order_header_in

SALES_HEADER_INX = order_header_inx

BUSINESS_OBJECT = 'BUS2096'

STATUS_BUFFER_REFRESH = 'X'

TABLES

RETURN = return

SALES_ITEMS_IN = order_items_in

SALES_ITEMS_INX = itemx

SALES_PARTNERS = order_partners

SALES_CONDITIONS_IN = sales_cond_in

SALES_CONDITIONS_INX = sales_cond_inx

.

Please let me know how you solved this problem??

Thanks in Advance.

Read only

Subhankar
Active Contributor
0 Likes
853

Hi,

Yes it will work. You can also use the BAPi BAPI_SALESORDER_CREATEFROMDAT2 to craete the credit note. Here you need to populate the partner table sales_partners. For header ITM_NUMBER will be 000000 and for item it will be like 10, 20 etc.

Thanks

Subhankar

Read only

brad_bohn
Active Contributor
0 Likes
853

You can also use the BAPi BAPI_SALESORDER_CREATEFROMDAT2 to craete the credit note

Errr, have you ever tried to create a credit memo request with BAPI_SALESORDER_CREATEFROMDAT2? I think you'll find that it doesn't work and that's why he's using SD_SALESDOCUMENT_CREATE...check the code, you'll see why.