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

Insert records into ztable

Former Member
0 Likes
554

Hi Team,

Please help me out here.

I have requirement, where we needs insert records to ztable.

here it is,

I have papulated vbak and vbap internal tables. I used parallel cursor method for this,

nw i needs it insert each record into ztable, where ztable contains both vbak and vbap fields.

ex. for one sales order no, 3 line items are there. so i need to insert 3 records for 3 line items along with vbak values.

Thanks & regrdas,

Mohan

Hi Team,

Please help me out here.

I have requirement, where we needs insert records to ztable.

here it is,

I have papulated vbak and vbap internal tables. I used parallel cursor method for this,

nw i needs it insert each record into ztable, where ztable contains both vbak and vbap fields.

ex. for one sales order no, 3 line items are there. so i need to insert 3 records for 3 line items along with vbak values.

Thanks & regrdas,

Mohan

2 REPLIES 2
Read only

ThomasZloch
Active Contributor
0 Likes
517

More a logical than a programming problem.

Similar to flat ALV lists, repeat the header fields for each line item.

Thomas

P.S. very basic, un-marked as question

Read only

amy_king
Active Contributor
0 Likes
517

Hi Mohan,

Take a look at the following nested loop to see a basic example of how you might approach such a problem (there are other solutions as well).

LOOP AT header ASSIGNING <header>.

     ls_ztable_struc-field1 = <header>-field1.
     ls_ztable_struc-field2 = <header>-field2.

     LOOP AT item ASSIGNING <item>
                               WHERE keyfield = <header>-keyfield.

          ls_ztable_struc-field3 = <item>-field1.
          ls_ztable_struc-field4 = <item>-field2.

          INSERT ztable FROM ls_ztable_struc.
          IF sy-subrc IS NOT INITIAL.
              ...handle error...
          ENDIF.

     ENDLOOP. " <item>

ENDLOOP. " <header>

Cheers,

Amy