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: 

BAPI_SALESORDER_CREATEFROMDAT2

Former Member
0 Kudos

Hi Friends,

In my function module of reuse_alv_grid_display, I have sold to party, item number, material number, quantity and UOM in T_OUTTAB = ITAB. I am using a subroutine to create sales order using bapi_salesorder_createfromdat2.

How to I need to declare the it_zat_usage table data inside my subroutine. I am using subroutines first time and please suggest me ideas.

Example:

FORM CREATE_SO.

LS_ORDERITEMSIN-ITM_NUMBER = ******

LS_ORDERITEMSIN-MATERIAL = ******

LS_ORDERITEMSIN-TARGET_QTY = ******

LS_ORDERITEMSIN-TARGET_QU = ******

APPEND LS_ORDERITEMSIN TO LT_ORDERITEMSIN.

CLEAR LS_ORDERITEMSIN.

ENDFORM.

Thanks.

Edited by: nani on May 20, 2011 10:53 AM

1 ACCEPTED SOLUTION

former_member191735
Active Contributor
0 Kudos

> How to I need to declare the it_zat_usage table data inside my subroutine. I am using subroutines first time and please suggest me ideas.

Declare it as another internal table. If you want to use outside of the subroutine, declare as global or else declare local.

9 REPLIES 9

former_member191735
Active Contributor
0 Kudos

> How to I need to declare the it_zat_usage table data inside my subroutine. I am using subroutines first time and please suggest me ideas.

Declare it as another internal table. If you want to use outside of the subroutine, declare as global or else declare local.

0 Kudos

Can you please give me some example according to my scenario?

Thanks.

0 Kudos

You can declare as same for local or global per your naming conventions.

Here is the way you need to declare.

If you are reference to a structure....

data: it_zat_usage type table of xyz_structure.

if you need to define from scratch , first define a type and then internal table.

types: begin of type_xyz,

fld1 type type1,

fld2 type type2,

end of type_xvy.

data: it_internal_table type table of type_xyz.

I am not sure about your requirement so i cannot define it for you.

0 Kudos

Hi sampath,

I need to pass the ship to partner data to my bapi.

global data declaration.

data: GV_SOLD LIKE BAPISOLDTO-SOLD_TO.

Inside the routine.

GS_ORDERPARTNERS-PARTN_NUMB = GV_SOLD.

when I debugg, I don't see any value in gv_sold. If I pass the value manually in my debuggger, it throws me an error saying that "In the function module interface, you can specify only fields of a specific type and length under "SOLD_TO_PARTY". Although the currently specified field GS_ORDERPARTNERS-PARTN_NUMB is correct type, its length is incorrect.

Please drive me in a correct way.

Thanks in advance.

0 Kudos

Ok. I must have misunderstand your requirement but here is what you can do...

The one you defined and assigned is good enough but you need to populate the data for GV_SOLD .

For example, if you have the data available in internal table (say the one that you are displayed in ALV), then you have to read the internal table into work area (required line with using KEY) and then assign the sold to party value to GV_SOLD after defining it.

GV_SOLD will then need to be assigned to BAPI variable. You could directly do that.

If you dont understand, provide your internal table that you are passing to ALV (add that internal table defination) and ask us what are you trying to achieve.

0 Kudos

This is what I have done. Please guide me if I am wrong.

Moderator message - Please respect the 5,000 character maximum when posting. Post only the relevant portions of code

Thanks.

Edited by: Rob Burbank on May 20, 2011 3:50 PM

0 Kudos

Alright, you dont have to define anything in the subroutine..CREATE_SO_DELIV but you have to read the record from internal table IT_ZAT_USAGE.

Within the subroutine

Read table IT_ZAT_USAGE into WA_ZAT_USAGE index SELFIELD-TABINDEX.

  • This statement reads the data into WA_ZAT_USAGE and the record is the one double clicked on

Once it reads the document int WA_ZAT_USAGE - You can put a break point here and run through. You should see the values

I am not sure about the internal table structure but you need more data to create sales order.

make sure to get items, partners, order type and so on.... To start with, use above statements to get the data into work area and see that in debug then decide what other information you required.

To pass the information to your bapi

For example,

gs_orderpartners-partn_numb = gv_sold.

you can do the following

gs_orderpartners-partn_numb = wa_zat_usage-kunnr.

good luck

0 Kudos

Hi Sampath,

Thanks for your response. I have already done that like this.

Data : gv_sold type bapisoldto-sold_to.

read table it_zat_usage into wa_zat_usage index 1.

gv_sold = wa_zat_usage-kunnr.

In my FM,

ship_to_party = gv_sold.

But when I execute the program it throws me into dump saying that "In the FM interface you can specify only fields of a specific type and length under "sold_to_party". although the currently specified field "gv_sold is the correct type, it's length is incorrect."

Please anybody help me with this.

Thanks.

0 Kudos

I am closing this thread since my problem is solved.