Skip to Content
-2
Oct 17, 2019 at 06:03 AM

ABAP - update table vbap

562 Views

Hi,

I have the following code to update the table VBAP based on gt_record1 entries, which I got from file upload. Gt_record1 has ordnum, item, plant, item category data. I have to update table VBAP with plant and item cat for provided ordnum and item.

I am doing something wrong with my loops. Can you please help.

Form get_data.

If gt_record1 is not initial.

sort gt_record1.

select * from vbap into table @data(lt_vbap)

for all entries in @gt_record1

where vbeln = @gt_record1-ordnum

and posnr = @gt_record1-item.

Loop at gt_record1 assigning field-symbol(<fs_record1>).

If sy-subrc = 0.

Loop at lt_vbap assigning field-symbol(<fs_vbap>).

<fs_vbap>-werks = <fs_record1>-plant.

<fs_vbap>-pstyv = <fs_record1>-itemcat.

ENDLOOP.

MODIFY vbap FROM TABLE lt_vbap.

If sy-subrc = 0.

COMMIT WORK.

ENDIF.

ENDIF.

ENDLOOP.

ENDIF.

ENDFORM.