‎2012 Jan 05 4:36 PM
hiii all,
i want to loop on columns of internal table.suppose while i am looping an internal table i have 4 amount field columns. so once it comes into loop i want to convert all the 4 amount field columns to other currency. so i want to convert the 4 amount columns of each row of an internal table. can anyone of you help me in this please.
thanks in advance,
Anil.
‎2012 Jan 05 4:46 PM
loop at itab assigning <fs>
<fs>-col1 = req1.
<fs>-col2 = req2.
endloop.
‎2012 Jan 05 4:46 PM
loop at itab assigning <fs>
<fs>-col1 = req1.
<fs>-col2 = req2.
endloop.
‎2012 Jan 05 4:50 PM
hii sowmya,
thx for responding for my question firstly. my requirment is in internal table i have 4 amount fields like wrbtr,wrbtr1,wrbtr2 etc.
once we do loop and single row enters into workarea i have to convert each amount field coulmn i.e wrbtr ,wrbtr1 etc into other currency using function module. so i got struck up at how to do looping each column of an internal table.
can you please help me in this.
thanks,
Anil.
‎2012 Jan 05 4:56 PM
LOOP AT ITAB ASSIGNING <FIELD_SYMBOL>
ASSIGN COMPONENT <FIELD_SYMBOL>-wrbtr of structure <internal table structure> to <fs>.
.convert amount
ASSIGN COMPONENT <FIELD_SYMBOL>-wrbtr1 of structure <internal table structure> to <fs>.
convert amount
ASSIGN COMPONENT <FIELD_SYMBOL>-wrbtr2 of structure <internal table structure> to <fs>.
I think this should work.
‎2012 Jan 05 4:59 PM
hi Bhanu,
that was an helpful answer but i want an reference program or any other detailed code so that it could be more helpful to me.can you provide any code or any reference program to me.
thanks,
Anil.
‎2012 Jan 05 5:11 PM
Hi,
types:
BEGIN OF TY_FIELDNAME,
FIELD_NAME TYPE C LENGTH 100,
SEARCH_STRING TYPE STRING,
END OF TY_FIELDNAME .
FIELD-SYMBOLS: <FIELD_NAME> TYPE TY_FIELDNAME,
FIELD-SYMBOLS: <FS_JOB_LIST> TYPE ANY,
I am using below code to find some text in each column of my internal table.
LOOP AT IT_FIELD_NAME ASSIGNING <FIELD_NAME>.
ASSIGN COMPONENT <FIELD_NAME>-FIELD_NAME OF STRUCTURE <FS_JOB_LIST> TO <FIELD>.
FIND FIRST OCCURRENCE OF REGEX I_SEARCH_STRING
IN <FIELD> IN CHARACTER MODE
IGNORING CASE
RESULTS RESULT_TAB.
‎2012 Jan 05 5:20 PM
Hiii,
actuallly i am using like this.
loop at itab.
here i get itab-waerk,itab-wrbtr,itab-wrbtr1,itab-wrbtr2.
now i have to convert each field i.e itab-wrbtr,itab-wrbtr1 to other currency using FM.
but i need to know how to loop each column from row here.
endloop.
can you provide any help how to solve this.
thanks,
Anil.
‎2012 Jan 05 5:27 PM
Try like this:
loop at itab ASSIGNING <fs>.
ASSIGN COMPONENT <fs>-waerk of STRUCTURE (itab structure) to <field> (this statement now will hold the value of <fs>-waerk )
convert the currency using <fs>-waerk pass this to your F.M
call f.m currency converted
importin = <fs>-waerk
exporting = <fs>-waerk (converted currency)
pass the converted value back to <fs>-waerk
<fs>-waerk = <field>
similarly <fs>-wrbtr
<fs>-wrbtr1
<fs>-wrbtr2
endloop.
‎2012 Jan 05 5:29 PM
you dont loop in the columns... loop is for ROWS. get this clear first.
say your itab is of type it_type
then define a field symbol of type it_type. why field symbol? because its like pointer in C. no need of workarea. data updated in field symbol will directly get updated in the table columns,
so..
loop at itam assigning <fs>.
call function XYZ
exporting abc = <fs>-wrbtr1
importing def = <fs>-wrbtr1.
call function XYZ
exporting abc = <fs>-wrbtr2
importing def = <fs>-wrbtr2.
call function XYZ
exporting abc = <fs>-wrbtr3
importing def = <fs>-wrbtr3.
call function XYZ
exporting abc = <fs>-wrbtr4
importing def = <fs>-wrbtr4.
endloop.
‎2012 Jan 05 5:33 PM
Hiii sowmya,
i need to loop the columns in a row. actually i told correctly.because generally we do loop for rows.but in a single row if there are multiple amount fields need to be converted then we have to do loop for those columns in each row.
actuallly i am using like this.
loop at itab.
here i get itab-waerk,itab-wrbtr,itab-wrbtr1,itab-wrbtr2.
now i have to convert each field i.e itab-wrbtr,itab-wrbtr1 to other currency using FM.
but i need to know how to loop each column from row here.
endloop.
can you provide any help how to solve this.
thanks,
Anil.
‎2012 Jan 05 5:44 PM
anil. can you please explain me whats wrong in the code i gave you?
‎2012 Jan 05 5:48 PM
hey dont mind otherwise.
there is nothing wrong in ur code.but my need is different. so i just explained u clearly regarding my requirement so u can help me in bit closer. nothign much.sry if i hurt you.
thanks,
Anil.
‎2012 Jan 05 7:53 PM
How clearly do you want the statements made....LOOP processes ROWs, not columns. We must handle each column in the row individually....
You have already received two good answers from which you can solve the problem.
‎2012 Jan 05 5:35 PM
‎2012 Jan 06 6:53 AM
Anil,
As per you requirement assume your internal table is as below.
Types: begin of ty_itab.
sno type char1,
wrbtr1
wrbtr2
wrbtr3
wrbtr4,
end of ty_itab.
data: i_itab type standard table of ty_itab with header line.
if this is the case, then why is that you want to loop at columns....which is not possible without field symbols.
For coverting amounts into currency.....all you have to do is for each row call the FM four times.....
LOOP AT i_itab...
Call function to convert wrbtr1 to currency1.
Call function to convert wrbtr2 to currency2.
Call function to convert wrbtr3 to currency3.
Call function to convert wrbtr4 to currency4.
Modify it_itab.
ENDLOOP.