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: 

Itab with data from VBFA

Former Member
0 Kudos

Hi,

for an sales order i found some entries in the VBFA and have will fill this

data in an internal table. I have to select only delivery, goods movement and Invoice for an sales order. Finding this data is no problem but i have problems

to fill the internal table.

DATA: begin of itab occurs 0,

vbeln_s like vbfa-vbelv, "Sales Order

vbeln_j like vbfa-vbeln, "Delivery

vbeln_r like vbfa-vbeln, "Goods movement

vbeln_m like vbfa-vbeln, "Invoice.

end of itab.

the itab shell be filled like this with 3 Deliveries and 5 invoices:

vbeln_s vbeln_j vbeln_r vbeln_m

2121 80000001 4900000001 90000001

2121 80000002 4900000002 90000002

2121 80000003 4900000003 90000003

2121 90000004

2121 90000005

Any idea? Thanks.

Regards, Dieter

The values 90000004 and 90000005 shell be under vbeln_M

Dieter

Message was edited by:

Dieter Gröhn

1 ACCEPTED SOLUTION

former_member223537
Active Contributor
0 Kudos

HI,

data : begin of itemp occurs 0,

vbeln_r like vbfa-vbeln, "Goods movement

vbeln_m like vbfa-vbeln, "Invoice.

end of itemp.

DATA: begin of itab occurs 0,

vbeln_s like vbfa-vbelv, "Sales Order

vbeln_j like vbfa-vbeln, "Delivery

<b>---> Include table i_temp here</b>

end of itab.

Best regards,

Prashant

7 REPLIES 7

Former Member
0 Kudos

Use FM - 'RV_ORDER_FLOW_INFORMATION'

Call the FM RV_ORDER_FLOW_INFORMATION to get the subsequent document for the corresponding sales document.

Reward points if helpful

Message was edited by:

Mayank Agarwal

0 Kudos

Hi Mayak,

the problem is not to get the data. My problem is to fill the internal

table like i have shown.

Regards, Dieter

former_member223537
Active Contributor
0 Kudos

HI,

data : begin of itemp occurs 0,

vbeln_r like vbfa-vbeln, "Goods movement

vbeln_m like vbfa-vbeln, "Invoice.

end of itemp.

DATA: begin of itab occurs 0,

vbeln_s like vbfa-vbelv, "Sales Order

vbeln_j like vbfa-vbeln, "Delivery

<b>---> Include table i_temp here</b>

end of itab.

Best regards,

Prashant

0 Kudos

Hi Prashant,

here my code

TABLES: VBFA. "Vertriebsbelegfluß

*

TYPES: BEGIN OF S_ITAB,

VBELN LIKE VBAK-VBELN,

VBELL LIKE LIKP-VBELN,

VBELM LIKE MKPF-MBLNR,

VBELF LIKE VBRK-VBELN,

END OF S_ITAB.

*

DATA: ITAB TYPE TABLE OF S_ITAB.

DATA: WA_ITAB TYPE S_ITAB.

*

DATA: VBELN LIKE VBFA-VBELN VALUE '0000001499'.

*

SELECT * FROM VBFA WHERE VBELV = VBELN.

WA_ITAB-VBELN = VBFA-VBELV.

CASE VBFA-VBTYP_N.

WHEN 'J'. "Lieferung

WA_ITAB-VBELL = VBFA-VBELN.

COLLECT WA_ITAB INTO ITAB.

WHEN 'R'. "Warenbewegung

WA_ITAB-VBELM = VBFA-VBELN.

COLLECT WA_ITAB INTO ITAB.

WHEN 'M'. "Faktura

WA_ITAB-VBELF = VBFA-VBELN.

COLLECT WA_ITAB INTO ITAB.

ENDCASE.

ENDSELECT.

*

SORT ITAB.

*

LOOP AT ITAB INTO WA_ITAB.

WRITE: / WA_ITAB-VBELN,

WA_ITAB-VBELL,

WA_ITAB-VBELM,

WA_ITAB-VBELF.

ENDLOOP.

I get this:



1499 80001484
1499 80001484 90001971
1499 80001484 4900045286 90001971
1499 80001484 4900045286 90002245
1499 80001484 4900050223 90001971
1499 80001484 4900050223 90002244
1499 80001674 4900049657 90002222
1499 80001674 4900052390 90002222
1499 80001674 4900052390 90002325
1499 80001691 4900045286 90001971
1499 80001691 4900045286 90002244
1499 80001691 4900049657 90002222
1499 80001691 4900049657 90002244
1499 80001691 4900050223 90002244
1499 80001698 4900050223 90002244
1499 80001698 4900050223 90002255
1499 80001698 4900050453 90002255
1499 80001708 4900050453 90002255
1499 80001708 4900050453 90002268
1499 80001708 4900050809 90002268
1499 80001713 4900050809 90002268
1499 80001713 4900050809 90002276
1499 80001713 4900051111 90002276
1499 80001731 4900051111 90002276
1499 80001731 4900051111 90002299
1499 80001731 4900051530 90002299
1499 80001743 4900051530 90002299
1499 80001743 4900051530 90002325
1499 80001743 4900052390 90002325

but i whant this in itab:

1499 80001484 4900045286 90001971

1499 80001674 4900049657 90002222

1499 80001691 4900050223 90002244

1499 80001698 4900050453 90002245

1499 80001708 4900050809 90002255

1499 80001713 4900051111 90002268

1499 80001731 4900051530 90002276

1499 80001743 4900052390 90002299

1499 90002325

Regards, Dieter

0 Kudos

delete itab where VBELM is initial.

delete itab where VBELF is initial.

loop at itab.

at first VBELL.

read table itab with key VBELL = itab-VBELL.

write: itab.

endat.

endloop.

Sorry AT NEW VBELL. not at first

Message was edited by:

Sumi Vasu

former_member223537
Active Contributor
0 Kudos

TABLES: VBFA. "Vertriebsbelegfluß

*

TYPES: BEGIN OF S_ITAB,

VBELN LIKE VBAK-VBELN,

VBELL LIKE LIKP-VBELN,

VBELM LIKE MKPF-MBLNR,

VBELF LIKE VBRK-VBELN,

END OF S_ITAB.

*

DATA: ITAB TYPE TABLE OF S_ITAB.

DATA: WA_ITAB TYPE S_ITAB.

*

DATA: VBELN LIKE VBFA-VBELN VALUE '0000001499'.

*

SELECT * FROM VBFA WHERE VBELV = VBELN.

WA_ITAB-VBELN = VBFA-VBELV.

CASE VBFA-VBTYP_N.

WHEN 'J'. "Lieferung

WA_ITAB-VBELL = VBFA-VBELN.

COLLECT WA_ITAB INTO ITAB.

WHEN 'R'. "Warenbewegung

WA_ITAB-VBELM = VBFA-VBELN.

COLLECT WA_ITAB INTO ITAB.

WHEN 'M'. "Faktura

WA_ITAB-VBELF = VBFA-VBELN.

COLLECT WA_ITAB INTO ITAB.

ENDCASE.

ENDSELECT.

*

SORT ITAB.

*

LOOP AT ITAB INTO WA_ITAB.

if l_vbeln ne wa_itab-vbeln.


WRITE: / WA_ITAB-VBELN,
WA_ITAB-VBELL,
WA_ITAB-VBELM,
WA_ITAB-VBELF.

l_vbeln = wa_itab-vebln.

append wa_itab to ITAB_NEW.
endif.

ENDLOOP.

Message was edited by:

Prashant Patil

Former Member
0 Kudos

Hi,

thanks for answers!

i solve in anoter way by reading VBFA

2 times and fill 2 itabs.

After this i put this 2 itabs

to one itab.

Regards, Dieter