2013 Dec 12 9:35 AM
Dear Expert,
I am facing a peculiar issue even though it is an easy one but i am facing and so far unable to find the solution. in my reporting to create vendor, i have to compare to fields of character type, and if both character fields having the same content then CONTINUE should be triggered. but in my case it is not at all triggering the CONTINUE. my sample code is as follow. am just giving an abstract code as original is restricted.
types: begin of gty_itab,
f1 type char10,
f2 type char24,
f3 type char10,
end of gty_itab.
data : gt_itab type table of gty_itab,
gw_itab type gty_itab.
constants: c_text type c length 24 value 'DO NOT ADD TO THE OUTPUT'.
gw_itab-f1 = '1st qtr'.
gw_itab-f2 = 'do not add to the output'.
gw_itab-f3 = 'vendor'.
append gw_itab to gt_itab.
clear gw_itab.
gw_itab-f1 = '2nd qtr'.
gw_itab-f2 = 'Regular'.
gw_itab-f3 = 'customer'.
append gw_itab to gt_itab.
clear gw_itab.
gw_itab-f1 = '3rd qtr'.
gw_itab-f2 = 'do not add to the output'.
gw_itab-f3 = 'vendor1'.
append gw_itab to gt_itab.
clear gw_itab.
gw_itab-f1 = '4th qtr'.
gw_itab-f2 = 'irregular'.
gw_itab-f3 = 'vendor'.
append gw_itab to gt_itab.
clear gw_itab.
loop at gt_itab into gw_itab.
*translate gw_itab-f2 to upper case.
if ( gw_itab-f2 = c_text )..
continue.
endif.
write: / gw_itab-f1, gw_itab-f2, gw_itab-f3.
endloop.
Early reply will be apprecieated and rewarded.
Regards
2013 Dec 12 9:46 AM
hi pritee,
just uncoment your line which starts wit translate it works fine..
2013 Dec 12 9:39 AM
2013 Dec 12 9:45 AM
Hi Naveet,
Translate gw_itab-f2 to upper case is needed as sometime the user may input "Do not add to the output" and there is a chance that some time the user may give "do not add to the output".so need to change it to upper case and checking against the content of c_text(DO NOT ADD TO THE OUTPUT). if both are same then CONTINUE should be executed and that particular line should not be displayed in the output.
Please suggest if you any other solution.
Regards
2013 Dec 12 9:48 AM
Hi Madan,
Even after commenting the "translate gw_itab-f2 to upper case", it is still not executing the CONTINUE statement.
Regards
2013 Dec 12 9:50 AM
it is executing , in my case . i just uncommented it and it worked as you suggested . check whether the condition values are equal or not.
2013 Dec 12 9:46 AM
hi pritee,
just uncoment your line which starts wit translate it works fine..
2013 Dec 12 9:51 AM
Hi Sivaganesh,
thanks for your reply. and also thanks to Nabheet also for his response.
Even after uncommenting the "translate gw_itab-f2 to upper case", it is still not executing the CONTINUE statement.
Any other solution for this.
Regards
2013 Dec 12 9:55 AM
Hi,
it works fine... but you can try this:
if ( gw_itab-f2 CS c_text ).
continue.
endif.
Regards,
2013 Dec 12 9:59 AM
you can try with CO (Contains only ) also
if ( gw_itab-f2 CO c_text ).
continue.
endif.
2013 Dec 12 10:06 AM
Thanks Bernat,
For your timely help. it solved my problem.thanks to Nabheet and Sivaganesh also. for ref purpose I am putting the code as follow.
types: begin of gty_itab,
f1 type char10,
f2 type char21,
f3 type char10,
end of gty_itab.
data : gt_itab type table of gty_itab,
gw_itab type gty_itab.
constants: c_text type c length 21 value 'Non-entity contractor'."'NON-ENTITY CONTRACTOR'.
gw_itab-f1 = 'rajesh'.
gw_itab-f2 = 'Non-entity Contractor'.
gw_itab-f3 = 'vendor'.
append gw_itab to gt_itab.
clear gw_itab.
gw_itab-f1 = 'rajesh1'.
gw_itab-f2 = 'Regular'.
gw_itab-f3 = 'customer'.
append gw_itab to gt_itab.
clear gw_itab.
gw_itab-f1 = 'rajesh2'.
gw_itab-f2 = 'Non-entity Contractor'.
gw_itab-f3 = 'vendor1'.
append gw_itab to gt_itab.
clear gw_itab.
gw_itab-f1 = 'rajesh5'.
gw_itab-f2 = 'irregular'.
gw_itab-f3 = 'vendor'.
append gw_itab to gt_itab.
clear gw_itab.
loop at gt_itab into gw_itab.
*translate gw_itab-f2 to upper case.
if ( gw_itab-f2 CS c_text )..
continue.
endif.
write: / gw_itab-f1, gw_itab-f2, gw_itab-f3.
endloop.
Regards
2013 Dec 12 10:10 AM
Your sample code works as expected.
It is not the continue line but the translate line you should bother about. Make sure it is executed.
set a break-point after the translate statemnt and check in debugger.
If in doubt, make use of the compare feature in debugger (second last tab).
Regards Jörg
2013 Dec 12 10:11 AM
Thanks Siva Ganesh,
Will try out your suggested solution.
Regards
Priteeranjan Nayak
2013 Dec 12 10:14 AM
Thanks Jorg,
for the input. for the time being it is working. will be waiting for the client to come up with any other requirement related to this. will be trying out as told by you.
Thanks
Regards
Priteeranjan Nayak
2013 Dec 12 10:03 AM
Pritee, If you need more information about comparing two strings, check this link.
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3516358411d1829f0000e829fbfe/content.htm
Thanks and regards !!
2013 Dec 12 10:09 AM
2013 Dec 12 10:19 AM
Hi Pritee Ranjan Nayak,
In your code you have a field ' c_text' which contains a constant value 'DO NOT ADD TO THE OUTPUT'.
You are filling the internal table with the 4 rows of values.
I have rewritten your code plz go through it.
REPORT ZTEM.
types: begin of gty_itab,
f1 type char10,
f2 type char24,
f3 type char10,
end of gty_itab.
data : gt_itab type table of gty_itab,
gw_itab type gty_itab.
constants: c_text(24) type c value 'DO NOT ADD TO THE OUTPUT'.
gw_itab-f1 = '1st qtr'.
gw_itab-f2 = 'do not add to the output'.
gw_itab-f3 = 'vendor'.
append gw_itab to gt_itab.
clear gw_itab.
gw_itab-f1 = '2nd qtr'.
gw_itab-f2 = 'Regular'.
gw_itab-f3 = 'customer'.
append gw_itab to gt_itab.
clear gw_itab.
gw_itab-f1 = '3rd qtr'.
gw_itab-f2 = 'do not add to the output'.
gw_itab-f3 = 'vendor1'.
append gw_itab to gt_itab.
clear gw_itab.
gw_itab-f1 = '4th qtr'.
gw_itab-f2 = 'irregular'.
gw_itab-f3 = 'vendor'.
append gw_itab to gt_itab.
clear gw_itab.
loop at gt_itab into gw_itab.
translate gw_itab-f2 to upper case.
if c_text eq gw_itab-f2 .
continue.
endif.
write: / gw_itab-f1, gw_itab-f2, gw_itab-f3.
clear gw_itab.
endloop.
Output of your code.
Hope this helps you
Regards
Rounak