Skip to Content
Nov 05, 2020 at 06:23 PM

How to read character wise character of a CHAR type variable of length 30


Hello Experts,

I have a field of ATWRT CHAR type length is 30. Now suppose it has a value ZZXX then I need to use these 4 characters (Z,Z,X and X) separately and fetch data from a DB table as this table has a corresponding value for each of these character.

For example: In the table if I pass Z, it will return 8 similarly for X it will return 6 so from this example I will get 8866. Now my question here is suppose ATWRT has a value of 30 characters (for EX: ABCDEFGHIJKLMNOPQRSTUVWXYZABCD) then what is the best way to pass this value to the table. Another example is suppose I have ZZXX then I am thinking

lv_field1 = atwrt+0(1).

lv_field2 = atwrt+1(2).

lv_field3 = atwrt+2(3).

lv_field4 = atwrt+3(4).

Append lv_field1 to lt_atwrt. Append lv_field2 to lt_atwrt. Append lv_field3 to lt_atwrt. Append lv_field4 to lt_atwrt.

Select * from DBTABLE into lt_table for all entries in LT_ATWRT where lv_value in lt_atwrt-value. But this is not the best way to do it, so can anyone suggest what should be the best way of doing it?