‎2007 Jul 05 11:26 AM
How would you modify an infotype for fields with repetitive structure? Can you give me an example program?
‎2007 Jul 05 11:59 AM
Hi Naveen,
Imagine you have a record in infotype 0027. If you want to modify that record use Do -- VARYING statement as shown below.
data: v_kbu01 type bukrs,
v_kgb01 type gsber,
v_kst01 type kostl,
v_kpr01 type pkprz.
data: wa_0027 like it_0027.
select * from pa0027
into table it_0027.
clear: wa_0027.
read table it_0027 into wa_0027 with key pernr = it_0001-pernr
binary search.
if sy-subrc = 0.
clear: v_kbu01, v_kgb01, v_kst01, v_kpr01.
do 25 times
varying v_kbu01 from wa_0027-kbu01 next wa_0027-kbu02
varying v_kgb01 from wa_0027-kgb01 next wa_0027-kgb02
varying v_kst01 from wa_0027-kst01 next wa_0027-kst02
varying v_kpr01 from wa_0027-kpr01 next wa_0027-kpr02.
check whether company is initial.
if v_kbu01 is initial and v_kgb01 is initial.
exit.
endif.
what ever modifications you want do it here
enddo.
endif.
Message was edited by:
Velangini Showry Maria Kumar Bandanadham
‎2007 Jul 05 11:59 AM
Hi Naveen,
Imagine you have a record in infotype 0027. If you want to modify that record use Do -- VARYING statement as shown below.
data: v_kbu01 type bukrs,
v_kgb01 type gsber,
v_kst01 type kostl,
v_kpr01 type pkprz.
data: wa_0027 like it_0027.
select * from pa0027
into table it_0027.
clear: wa_0027.
read table it_0027 into wa_0027 with key pernr = it_0001-pernr
binary search.
if sy-subrc = 0.
clear: v_kbu01, v_kgb01, v_kst01, v_kpr01.
do 25 times
varying v_kbu01 from wa_0027-kbu01 next wa_0027-kbu02
varying v_kgb01 from wa_0027-kgb01 next wa_0027-kgb02
varying v_kst01 from wa_0027-kst01 next wa_0027-kst02
varying v_kpr01 from wa_0027-kpr01 next wa_0027-kpr02.
check whether company is initial.
if v_kbu01 is initial and v_kgb01 is initial.
exit.
endif.
what ever modifications you want do it here
enddo.
endif.
Message was edited by:
Velangini Showry Maria Kumar Bandanadham
‎2007 Jul 05 12:12 PM
thanks a lot...but i dint get the do--varying statement. What does it do actually?
why is this line needed???
check whether company is initial.
if v_kbu01 is initial and v_kgb01 is initial.
‎2007 Jul 05 12:30 PM
In the first do loop pass the values KBU01, KGB01, KST01, KPR01 gets filled into v_kbu01, v_kgb01, v_kst01, v_kpr01 respectively.
In the second Do loop pass KBU02, KGB02, KST02, KPR02 gets filled into v_kbu01, v_kgb01, v_kst01, v_kpr01 respectively.
what ever may be the Do loop pass, first you check whether the variable v_kbu01
is initial. If it is initial then there is no further values exist. So you can exit from the Do loop.
If you have two repeted structure values in the infotype 0027 record and you have no values for the fields KBU03, KGB03, KST03, KPR03. Now you can modify these fields based on sy-index. Why sy-index is now you are in Do loop pass 3 so sy-index will be 3. and check KBU03 is initial. So you can modify KBU03, KGB03, KST03, KPR03 with your values. like this you can fill the values based on sy-index and corresponding field values.