Skip to Content
0
Former Member
Jul 02, 2009 at 06:37 PM

select inside loop into for all entries or joins

38 Views

Experts please help in making it into for all entries or joins.

suppose assume this

zuser table has 2 fields usage and kunnr.

in i_table i always have 2 fields.

type

number

type will store user or nonuser

and number can store customer number or sales order number.

if the type is user then the numer will be customer number and

if the type is nonuser then the number will be sales order number.

and values in this table is like this

type number

user 100001210

nonuser 123200000

user 124573930

user 294839039

user 138393903

nonuser 382749239

type always have user or nonuser and corresponding to them we have customer numbers.

and now based on this we need to fine tune this code.

parameters :p_usage(20) type char

LOOP AT i_table.

IF i_table-type = 'NONUSER'.

SELECT single kunnr INTO skunnr FROM vbak WHERE

vbeln = i_table-value.

ENDIF.

ENDIF.

IF i_table-type = 'USER'.

skunnr = i_table-value.

ENDIF.

IF skunnr is not initial.

SELECT single usage FROM zuser

INTO v_usage

WHERE usage = p_usage

AND kunnr = skunnr.

IF v_usage IS NOT INITIAL.

i_export-kunnr = i_table-type.

i_export-auart = i_table-name.

i_export-flag = 'X'.

ELSE.

i_export-NAME = i_table-type.

i_export-age = i_table-name.

i_export-flag = ''.

ENDIF.

Append i_export to itab_final.

ENDIF.

ENDLOOP.

Moderator message - Moved to the correct forum

Edited by: Rob Burbank on Jul 2, 2009 2:53 PM