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

data extraction

Former Member
0 Likes
1,035

hi to all

in my senario i have to download all open purchase order exist in our organisation.

so iam selecting data from ekko / ekpo / and ekbe tables.

while fetching open quantity for a particular line item

i am make use of ekbe table , on that based on the type qualifier (credit /debit indicator) my quantity will have - / +.

i am using collect statement to check the pending quantity,thus using this i cant validate whether credit or debit.

select ebeln ebelp menge from ekbe into corresponding fields of wa_ekbe

for all entries in itab_ekko

where ebeln = itab_ekko-ebeln.

collect wa_ekbe into itab_ekbe.

endselect.

i am getting everything as positive value

how to proceed in this case

how to validate

regards

vijay

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
977

instead of --

select ebeln ebelp menge from ekbe into corresponding fields of wa_ekbe

for all entries in itab_ekko

where ebeln = itab_ekko-ebeln.

collect wa_ekbe into itab_ekbe.

endselect.

make it--

data : l_open type ekbe-menge.

select ebeln ebelp menge from ekbe into corresponding fields of <b>table t_ekbe</b>

for all entries in itab_ekko

where ebeln = itab_ekko-ebeln.

if sy-subrc eq 0.

sort t_ekbe by ebeln ebelp.

loop at t_ekbe.

if t_ekbe-shkzg eq 'H'.

l_menge = l_menge + t_ekbe-menge.

elseif t_ekbe-shkzg eq 'S'.

l_menge = l_menge - t_ekbe-menge.

endif.

at end of ebeln.

write: l_menge. (this has the open qty for every PO)

clear l_menge.

endat

endloop.

endif.

7 REPLIES 7
Read only

Former Member
0 Likes
978

instead of --

select ebeln ebelp menge from ekbe into corresponding fields of wa_ekbe

for all entries in itab_ekko

where ebeln = itab_ekko-ebeln.

collect wa_ekbe into itab_ekbe.

endselect.

make it--

data : l_open type ekbe-menge.

select ebeln ebelp menge from ekbe into corresponding fields of <b>table t_ekbe</b>

for all entries in itab_ekko

where ebeln = itab_ekko-ebeln.

if sy-subrc eq 0.

sort t_ekbe by ebeln ebelp.

loop at t_ekbe.

if t_ekbe-shkzg eq 'H'.

l_menge = l_menge + t_ekbe-menge.

elseif t_ekbe-shkzg eq 'S'.

l_menge = l_menge - t_ekbe-menge.

endif.

at end of ebeln.

write: l_menge. (this has the open qty for every PO)

clear l_menge.

endat

endloop.

endif.

Read only

Former Member
0 Likes
977

Hello Vijay,

The data element of field MENGE is sign independent and will not store the +/- sign in it. For this purpose you will need to use the field EKBE-SHKZG. This field stores the debit and credit indicators and should be combined with MENGE to get the required output.

Hope this helps.

Sudha

Message was edited by: Sudha Mohan

Read only

0 Likes
977

thanks

Read only

0 Likes
977

thanks

Read only

Former Member
0 Likes
977

Hi,

COLLECT allows you to create unique or summarized datasets. The system first tries to find a table entry corresponding to the table key. The key values are taken either from the header line of the internal table itab, or from the explicitly-specified <b>work area wa</b>. The line type of itab must be flat - that is, it cannot itself contain any internal tables. All the components that do not belong to the key must be numeric types ( ABAP Numeric Types).

If the system finds an entry, the numeric fields that are not part of the table key are added to the sum total of the existing entries. If it does not find an entry, the system creates a new entry instead.

The way in which the system finds the entries depends on the kind of the internal table.

May be you can selet the data as per your requirement and store those records into internal table.

After this you can use below code:

SORT the table if required.

LOOP AT <itab1> INTO <wa1>.

READ TABLE <itab2> INTO <wa2> [WITH KEY] [BINARY SEARCH].

<wa2-field value> = <wa1-field value>

COLLECT <wa2> INTO <itab2>.

ENDLOOP.

<b>Reward if helpful</b>

Rgds,

Read only

Former Member
0 Likes
977

Vijay,

You cannot use COLLECT statement here. MENGE is not a key field.

I think your code should be modified as follows

select * (DONT USE STAR)from ekbe into corresponding fields of table lt_ekbe

for all entries in itab_ekko

where ebeln = itab_ekko-ebeln.

loop at lt_ekbe into wa_ekbe.

***check the indicator to convert the quantity to +ve or -ve

***use control statements here to calculate the quantity

endloop.

Thanks,

Read only

Former Member
0 Likes
977

i guess i have solved ur problem in my earlier reply. Do let me know if you want some more details.