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

version changed from 4.6 to ecc6.0

Former Member
0 Likes
1,457

i have to write code as per ECC 6.0

LOOP AT it_likp INTO wa_likp.

wa_output-werks = wa_likp-werks.

wa_output-vrkme = wa_likp-vrkme.

wa_output-lfimg = wa_likp-lfimg.

IF wa_output-werks <> ' '.

SELECT name1 FROM t001w INTO wa_output-plant1

WHERE werks = wa_output-werks

AND spras = sy-langu.

ENDSELECT. ""#EC CI_USE_WANTED

ENDIF.

append wa_output to it_output.

end loop.

now the above code is as per 4.6 version.

as per ECC 6.0 please tell how to write select statemnet out side the loop and read statement in side the loop..

please give coding for that

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,430

Hi..

try this..

it_tab, wa_tab are internal table nad work area respectively.

SELECT name1 FROM t001w INTO table it_tab

for all entries in it_likp

WHERE werks = it_likp-werks

AND spras = sy-langu.

LOOP AT it_likp INTO wa_likp.

move wa_likp-werks wa_output-werks .

move wa_likp-vrkme wa_output-vrkme.

move wa_likp-lfimg wa_output-lfimg .

if sy-subrc eq 0.

read table it_tab to wa_tab where werks = wa_likp-werks.

move wa_tab-name1 to wa_output-name1.

append wa_output to it_output.

endif.

endloop.

Regards,

Lokeswari.

Hi..

try this..

it_tab, wa_tab are internal table nad work area respectively.

SELECT name1 FROM t001w INTO table it_tab

for all entries in it_likp

WHERE werks = it_likp-werks

AND spras = sy-langu.

LOOP AT it_likp INTO wa_likp.

move wa_likp-werks wa_output-werks .

move wa_likp-vrkme wa_output-vrkme.

move wa_likp-lfimg wa_output-lfimg .

if sy-subrc eq 0.

read table it_tab to wa_tab where werks = wa_likp-werks.

move wa_tab-name1 to wa_output-name1.

append wa_output to it_output.

endif.

endloop.

Regards,

Lokeswari.

17 REPLIES 17
Read only

Former Member
0 Likes
1,430

the above code is not limited to 4.6 c or ECC 6.0 but its generic code which needs abap enhancement .

get this in a internal table


//SELECT name1 FROM t001w INTO wa_output-plant1
WHERE werks = wa_output-werks
AND spras = sy-langu.

name1 werks should be in internal table.
sort the internal table holding the entries.

LOOP AT it_likp INTO wa_likp.
wa_output-werks = wa_likp-werks.
wa_output-vrkme = wa_likp-vrkme.
wa_output-lfimg = wa_likp-lfimg.

IF wa_output-werks ' '.
read table itab with key werks = wa_likp-serks binary search. " just this 
if sy-subrc eq  0.
wa_output-plant1 = name ."check the entry 
endif.
ENDIF.
append wa_output to it_output.
end loop.

you are expected to do this on your own ..

...........

br,

Vijay

Read only

0 Likes
1,430

actually in the loop statemnet only we are getting values from wa_likp to wa_output.

before the loop statement wa_output-werks is empty.

how can we write select statement depending on wa_output-werks???

please tell in detail

Read only

0 Likes
1,430

Hi..

Did you try my code??

Regards,

Lokeswari.

Read only

0 Likes
1,430

t001w table has less than 500 entries .. whats the big deal in taking all the entries from the table .

take a internal table with two fields in it and using select fill the entries .. i hope it is clear to you ..

---

vijay

Read only

0 Likes
1,430

one more doubt

after selecting name1.

i wanted to write

IF wa_likp-lfart = 'ZPFL'.

SELECT vbelv

posnv

posnn

vbeln

vbtyp_n

INTO wa_vbfa

FROM vbfa

WHERE vbelv = wa_likp-vbeln

AND posnv = wa_likp-posnr

AND vbtyp_n = 'M'.

ENDSELECT.

endif.

let me know how to write correctly

because my data is in it_likp...........if i give wa_likp its empty

if i tried to give it_likp-lfart its telling there is no header line so it does not exists

Read only

Former Member
0 Likes
1,431

Hi..

try this..

it_tab, wa_tab are internal table nad work area respectively.

SELECT name1 FROM t001w INTO table it_tab

for all entries in it_likp

WHERE werks = it_likp-werks

AND spras = sy-langu.

LOOP AT it_likp INTO wa_likp.

move wa_likp-werks wa_output-werks .

move wa_likp-vrkme wa_output-vrkme.

move wa_likp-lfimg wa_output-lfimg .

if sy-subrc eq 0.

read table it_tab to wa_tab where werks = wa_likp-werks.

move wa_tab-name1 to wa_output-name1.

append wa_output to it_output.

endif.

endloop.

Regards,

Lokeswari.

Read only

0 Likes
1,430

Ur code is very helpful..

but i have declared

DATA: it_output TYPE STANDARD TABLE OF ty_output,

it_output1 TYPE STANDARD TABLE OF ty_output,

it_tab TYPE STANDARD TABLE OF ty_output.

it_tabe as just like ty_output.

as it is already defined.

and wa also like

DATA :wa_output LIKE LINE OF it_output,

wa_output1 LIKE LINE OF it_output1,

wa_tab type ty_output.

Ur code is working fine but at last when i am using read statemnet its not moving from it_tab to wa_tab.

if i am debugging for wa_tab its showing its non charlike structure??

can u tell me what to so

Read only

0 Likes
1,430

Hi..

try like this..

it_tab, wa_tab are internal table nad work area respectively.

SELECT *werks name1 * FROM t001w INTO table it_tab

for all entries in it_likp

WHERE werks = it_likp-werks

AND spras = sy-langu.

LOOP AT it_likp INTO wa_likp.

move wa_likp-werks wa_output-werks .

move wa_likp-vrkme wa_output-vrkme.

move wa_likp-lfimg wa_output-lfimg .

if sy-subrc eq 0.

read table it_tab to wa_tab where werks = wa_likp-werks.

move wa_tab-name1 to wa_output-name1.

append wa_output to it_output.

endif.

endloop.

Regards,

Lokeswari.

Read only

0 Likes
1,430

hi..

define it_tab like

types : begin of iy_tab,

werks type T001W-werks,

nem1 type T001W-name1,

end of iy_tab.

data : it_tab type standard table of iy_tab,

wa_tab type iy_tab.

Read only

0 Likes
1,430

hi,

As per ur code

if sy-subrc eq 0.

read table it_tab to wa_tab where werks = wa_likp-werks.

move wa_tab-name1 to wa_output-name1.

append wa_output to it_output.

endif.

endloop.

when i am using select statemnet i am getting data into it_tab.

but when i am using read statement it not moving to wa_tab

whats wrong in that???

Read only

0 Likes
1,430

Hi...

Check for the sy-subrc value before move statement and also check for values in it_likp table.

after moving it_likp values to wa_output only , we are able to move name field from wa_tab.

Regards,

Lokeswari.

Read only

0 Likes
1,430

Hi Deepthi,

Try this way:

If wa_likp-werks is not initial.
SELECT name1 FROM t001w INTO wa_output1-plant1
WHERE werks = wa_likp-werks
AND spras = sy-langu.
ENDSELECT. 
endif.

LOOP AT it_likp INTO wa_likp.
read table itab with key werks = wa_likp-werks.
if sy-subrc = 0.
wa_output-werks = wa_likp-werks.
wa_output-vrkme = wa_likp-vrkme.
wa_output-lfimg = wa_likp-lfimg.
endif.

IF wa_output-werks ' '.
wa_output-werks = wa_output1-name1.
ENDIF.
append wa_output to it_output.
endloop.

Press F1 help on read statemnt. Your syntax is wrong.

Read only

0 Likes
1,430

hi...

sorry for the previous replies..

try this code.. this time it will resolve your problem.

it_tab, wa_tab are internal table nad work area respectively.

SELECT name1 FROM t001w INTO table it_tab

for all entries in it_likp

WHERE werks = it_likp-werks

AND spras = sy-langu.

LOOP AT it_likp INTO wa_likp.

move wa_likp-werks wa_output-werks .

move wa_likp-vrkme wa_output-vrkme.

move wa_likp-lfimg wa_output-lfimg .

if sy-subrc eq 0.

read table it_tab to wa_tab with key werks = wa_likp-werks.

move wa_tab-name1 to wa_output-name1.

append wa_output to it_output.

endif.

endloop.

Regards,

Lokeswari.

Read only

0 Likes
1,430

Hi...

loop at it_likp to wa_likp

IF wa_likp-lfart = 'ZPFL'.

SELECT vbelv

posnv

posnn

vbeln

vbtyp_n

FROM vbfa

for all entries in it_likp

WHERE vbelv = it_likp-vbeln

AND posnv = it_likp-posnr

AND vbtyp_n = 'M'.

endif.

endloop.

Regards,

Lokeswari.

Read only

0 Likes
1,430

Hi...

loop at it_likp to wa_likp

IF wa_likp-lfart = 'ZPFL'.

SELECT vbelv

posnv

posnn

vbeln

vbtyp_n

FROM vbfa

WHERE vbelv = wa_likp-vbeln

AND posnv = wa_likp-posnr

AND vbtyp_n = 'M'.

endif.

endloop.

Regards,

Lokeswari.

Read only

former_member125931
Active Participant
0 Likes
1,430

{If wa_likp-werks is not initial.

SELECT name1 FROM t001w INTO wa_output1-plant1

WHERE werks = wa_likp-werks

AND spras = sy-langu.

ENDSELECT. ""#EC CI_USE_WANTED

endif.}

{LOOP AT it_likp INTO wa_likp.

wa_output-werks = wa_likp-werks.

wa_output-vrkme = wa_likp-vrkme.

wa_output-lfimg = wa_likp-lfimg.

IF wa_output-werks ' '.

wa_output-werks = wa_output1-name1.

ENDIF.

append wa_output to it_output.

end loop.}

Hope it will resolve ur problem..

Read only

former_member125931
Active Participant
0 Likes
1,430

HI Try my code,

you just need to do a simple change,

declare a work are wa_output1 same as wa_output.