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

BAPI_SALESORDER_CREATEFROMDAT2 vbkd-traty

Former Member
0 Likes
2,585

Hi experts

Anyone know how to pass the value of Means of Transport(VBKD-TRATY) to

BAPI BAPI_SALESORDER_CREATEFROMDAT2?

Thanks in Advance,

Shichun qing

7 REPLIES 7
Read only

Former Member
0 Likes
1,868

hi,

hope this will help you.

data : ORDER_HEADER_IN like BAPISDHD1.
DATA : SALESDOCUMENT LIKE  BAPIVBELN-VBELN.
data : RETURN like BAPIRET2 occurs 0 with header line.
data : ORDER_ITEMS_IN like BAPISDITM occurs 0 with
header line.
data : ORDER_PARTNERS like BAPIPARNR occurs 0 with
header line.
data : ORDER_SCHEDULES_IN like BAPISCHDL occurs 0 with
header line.
DATA : ORDER_KEYS LIKE BAPISDKEY OCCURS 0 WITH HEADER
LINE.

 CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
        EXPORTING
             ORDER_HEADER_IN               = ORDER_HEADER_IN
       IMPORTING
         SALESDOCUMENT                 = SALESDOCUMENT
        TABLES
         RETURN                        = RETURN
             ORDER_ITEMS_IN                = ORDER_ITEMS_IN

             ORDER_PARTNERS                = ORDER_PARTNERS
             ORDER_SCHEDULES_IN            = ORDER_SCHEDULES_IN
         ORDER_KEYS                    = ORDER_KEYS
                .

you can find all code from : http://www.sap-img.com/abap/bapi-salesorder-createfromdat2.htm

regards,

Orhan

Read only

0 Likes
1,868

Thanks,

But your sample have not field traty. I just want how to pass the field to BAPI. Anyway ,Thanks your reply.

Read only

0 Likes
1,868

hey,

if you want to use TRATY you can use function SD_SALESDOCUMENT_CREATE.

data: BUSINESS_EX_IN LIKE BAPISDBUSI.

BUSINESS_EX_IN-TRANS_CAT = 'YOUR'. " this field type is traty
APPEND BUSSINESS_EX_IN.

CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'
  EXPORTING
    SALES_HEADER_IN               = SALES_HEADER_IN
 TABLES
   BUSINESS_EX  = BUSINESS_EX_IN
*   RETURN                        =
          .

BAPISDBUSI has a field named TRANS_CAT type Traty. So i think u can use it. Or you can look other tables at FM SD_SALESDOCUMENT_CREATE to find a field typed TRATY.

Regards,

Orhan

Read only

0 Likes
1,868

Dear goktasor

We need create Sale order with BAPI_SALESORDER_CREATEFROMDAT2 .

No way update "vbkd-traty" using BAPI_SALESORDER_CREATEFROMDAT2 ?

Read only

0 Likes
1,868

hi,

u cannot use traty with this bapi. SD_SALESDOCUMENT_CREATE also create sales order so you can use it with code i wrote above.

regards,

orhan

Read only

0 Likes
1,868

Hi,

Regrettably is not possible use traty in this function, I have had the same problem and after of to search in the web I have decided after the function return the order number, Update it with a sql sentence.

The sentence is:

IF NOT salesdocument IS INITIAL.

  • Si no hubo error

resultado = 0.

mensaje = 'OK'.

idpedido = salesdocument.

  • Actualizo Clase de material de embalaje (Utilizado para tratamiento de fecha de entrega)

update vbkd

set vbkd~traty = cabecera-clase

where vbkd~VBELN = salesdocument.

ENDIF.

Perhaps it is not the better form, but this form was effective for me.

Read only

0 Likes
1,868

Thanks