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

problem in programe

laxman_sankhla3
Participant
0 Likes
682

hi

i m getting problem in loop.

in loop itab1.

i want to select data from konv i compare konv~knumv = itab1-knumv.

but in itab1-knumv no data is cmoing .

please help me.

LOOP AT ITAB.

READ TABLE ITAB1 WITH KEY EBELN = ITAB-EBELN.

  • IF ITAB1-EBELN = ITAB-EBELN.

IF sy-subrc eq 0.

ITAB1-EBELN = ITAB-EBELN.

ITAB1-LIFNR = ITAB-LIFNR.

  • ITAB1-EBELP = ITAB-EBELP.

ITAB1-BELNR = ITAB-BELNR.

ITAB1-KNUMV = ITAB-KNUMV.

ITAB1-NAME1 = ITAB-NAME1.

ITAB1-NAME2 = ITAB-NAME2.

ITAB1-GJAHR = ITAB-GJAHR.

modify itab1 index sy-tabix.

endif.

loop at itab1.

<b>select * from konv into corresponding fields of itab

for all entries in itab1

where knumv = itab1-knumv and

kposn = itab1-ebelp.</b>

READ TABLE ITAB1 .

  • WITH KEY KNUMV = ITAB-KNUMV.

IF ITAB-KSCHL = 'NAVS' OR ITAB-KSCHL = 'NAVM'.

ITAB1-KBETR = ITAB-KBETR.

modify ITAB1 transporting KBETR

where KNUMV = ITAB1-KNUMV .

ELSEIF ITAB-KSCHL = 'FRA1' OR ITAB-KSCHL = 'FRC1'

OR ITAB5-KSCHL = 'FRB1'.

ITAB1-KWERT = ITAB-KWERT.

modify ITAB1 transporting KBETR

where KNUMV = ITAB1-KNUMV .

ENDIF.

modify itab.

endselect.

ENDLOOP.

endloop.

Thanks in advanced.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
655

Hi

First fetch the data from EKKO and EKPo into ITAB

then

if not itab[] is initial.

select * from KONV into table ITAb1

for all entries in itab

where knumv = itab-knumv and

kposn = itab-ebelp.

endif.

loop at itab.

move-corresponding itab Data to final ITAB3.

read table itab1 with key knumv = itab-knumv

kposn = itab-ebelp.

if sy-subrc = 0.

<move the data to final ITAB3>

endif.

append ITAb3.

cklear ITAb3.

endloop.

use the ITAB3 table for your data display.

Reward points for useful Answers

Regards

Anji

6 REPLIES 6
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
655

Hi,

Sepeare the two loops

You can construct the itab1 first in one loop and then you can run a loop over the itab1 to execute another loop.

Regards,

Sesh

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
655

Hi,

You are looping itab and inside that you are writing the contents of knov into the same itab.That part needs to be changed.

select * from konv into corresponding fields of itab

for all entries in itab1

where knumv = itab1-knumv and

kposn = itab1-ebelp.

Moreover you are using for all entries for the entire itab1.So no need of loop at itab1 before that.

Read only

Former Member
0 Likes
655

hi,

write ur code like this,

add <b>table</b> keyword in select statement.

if not itab1[] is initial.

select * from konv into corresponding fields of <b>table</b> itab

for all entries in itab1

where knumv = itab1-knumv and

kposn = itab1-ebelp.

endif.

reward points if useful,

regards,

seshu.

Read only

Former Member
0 Likes
656

Hi

First fetch the data from EKKO and EKPo into ITAB

then

if not itab[] is initial.

select * from KONV into table ITAb1

for all entries in itab

where knumv = itab-knumv and

kposn = itab-ebelp.

endif.

loop at itab.

move-corresponding itab Data to final ITAB3.

read table itab1 with key knumv = itab-knumv

kposn = itab-ebelp.

if sy-subrc = 0.

<move the data to final ITAB3>

endif.

append ITAb3.

cklear ITAb3.

endloop.

use the ITAB3 table for your data display.

Reward points for useful Answers

Regards

Anji

Read only

0 Likes
655

HI ANJI ,

AS U TOLD I DID BUT WHAT IS HAPPENING .

I AM SELECTING DATA FROM KONV ON BASED ON ITAB-KNUMV AND ITAB-EBEPL.

IN KONV TABLE AGAINST KNUMV AND EBELP FOR ONE LINE ITEM NUMBER OF KSCHL CONDITION SO HERE WHAT IS HAPPENING

NO DATA IS COMING FOR KONV-KBETR AND KONV-KWERT.

CODE IS BELOW .

PLEASE HELP ME .

I WILL BE VERY THANKFULL TO U .

DATA: BEGIN OF itab OCCURS 0,

EBELN LIKE EKKO-EBELN,

KNUMV LIKE EKKO-KNUMV,

LIFNR LIKE EKKO-LIFNR,

EBELP LIKE KONV-KPOSN,

NETWR LIKE EKPO-NETWR,

NETPR LIKE EKPO-NETPR,

END OF itab.

DATA: BEGIN OF ITAB3 OCCURS 0,

EBELN LIKE EKKO-EBELN,

KNUMV LIKE EKKO-KNUMV,

LIFNR LIKE EKKO-LIFNR,

EBELP LIKE EKPO-EBELP,

NETWR LIKE EKPO-NETWR,

NETPR LIKE EKPO-NETPR,

KSCHL LIKE KONV-KSCHL,

KBETR LIKE KONV-KBETR,

KWERT LIKE KONV-KWERT,

END OF ITAB3.

DATA: BEGIN OF ITAB1 OCCURS 0,

KPOSN LIKE KONV-KPOSN,

KNUMV LIKE KONV-KNUMV,

KSCHL LIKE KONV-KSCHL,

KBETR LIKE KONV-KBETR,

KWERT LIKE KONV-KWERT, " THIS IS FOR FREIGHT

END OF ITAB1.

PERFORM GET_DATA.

PERFORM CALL_ALV_GRID.

FORM GET_DATA.

SELECT AEBELN ALIFNR AKNUMV BEBELP BNETWR BNETPR

FROM EKKO AS A

INNER JOIN EKPO AS B ON AEBELN = BEBELN

INTO CORRESPONDING FIELDS OF TABLE itab

WHERE B~BUKRS = 'GSPL' .

if not itab[] is initial.

select * from KONV into CORRESPONDING FIELDS OF TABLE ITAB1

for all entries in itab

where knumv = itab-knumv and

kposn = itab-ebelp.

endif.

loop at itab.

ITAB3-EBELN = ITAB-EBELN.

ITAB3-EBELP = ITAB-EBELP.

ITAB3-KNUMV = ITAB-KNUMV.

ITAB3-LIFNR = ITAB-LIFNR.

ITAB3-NETWR = ITAB-NETWR.

ITAB3-NETPR = ITAB-NETPR.

read table itab1 with key knumv = itab-knumv

kposn = itab-ebelp.

if sy-subrc = 0.

ITAB3-KSCHL = ITAB1-KSCHL.

IF ITAB3-KSCHL = 'NAVS' OR ITAB3-KSCHL = 'NAVM'.

ITAB3-KBETR = ITAB3-KBETR.

modify ITAB3 transporting KBETR

where KNUMV = ITAB3-KNUMV AND EBELP = ITAB3-EBELP .

ELSEIF ITAB3-KSCHL = 'FRA1' OR ITAB3-KSCHL = 'FRC1' OR

ITAB3-KSCHL = 'FRB1'.

ITAB3-KWERT = ITAB3-KWERT.

modify ITAB3 transporting KWERT

where KNUMV = ITAB3-KNUMV AND EBELP = ITAB3-EBELP .

ENDIF.

endif.

append itab3.

clear itab3.

endloop.

THANKS. PLEASE HELP

Read only

Former Member
0 Likes
655

hi laxman,

LOOP AT ITAB.

READ TABLE ITAB1 WITH KEY EBELN = ITAB-EBELN.

  • IF ITAB1-EBELN = ITAB-EBELN.

IF sy-subrc eq 0.

ITAB1-EBELN = ITAB-EBELN.

ITAB1-LIFNR = ITAB-LIFNR.

  • ITAB1-EBELP = ITAB-EBELP.

ITAB1-BELNR = ITAB-BELNR.

ITAB1-KNUMV = ITAB-KNUMV.

ITAB1-NAME1 = ITAB-NAME1.

ITAB1-NAME2 = ITAB-NAME2.

ITAB1-GJAHR = ITAB-GJAHR.

modify itab1 index sy-tabix.

endif.

<<< ENDLOOP <<

loop at itab1.

<<<< APPPENDING CORRESPONIDG FIELDS OF <<<<<<

select * from konv into corresponding fields of itab

for all entries in itab1

where knumv = itab1-knumv and

kposn = itab1-ebelp.

READ TABLE ITAB1 .

  • WITH KEY KNUMV = ITAB-KNUMV.

IF ITAB-KSCHL = 'NAVS' OR ITAB-KSCHL = 'NAVM'.

ITAB1-KBETR = ITAB-KBETR.

modify ITAB1 transporting KBETR

where KNUMV = ITAB1-KNUMV .

ELSEIF ITAB-KSCHL = 'FRA1' OR ITAB-KSCHL = 'FRC1'

OR ITAB5-KSCHL = 'FRB1'.

ITAB1-KWERT = ITAB-KWERT.

modify ITAB1 transporting KBETR

where KNUMV = ITAB1-KNUMV .

ENDIF.

modify itab.

endselect.

ENDLOOP.

<<< DELETE ENDLOOP HERE >>>>endloop.

STILL PROBLEM PLEAS GET BACK TO ME

REWARD IF USEFUL

THANKS

NAVEEN