‎2006 May 31 7:49 AM
Dear friends..
Good morning.
I wish to know.. how i segregate the field from a database table to internal table into two different internal table field. say for example.
i have db table tab1 which has field number
tab1 -> number
and i have another internal table itab1 whic has two fields numa and numb
tab1 -> numa
-> numb
i have value in tab1->number is 001 and 0001
i wish to segregate this two values in to internal table
if the value is 001 then it should be into 001 -> numa
if the value is 0001 then it should be into 0001-> numb
i dont know how to perform the string operations in internal table.. would you like to tell me how i fix this problem any suggetion, article, code will be great help of mine..
thanking you
Regards
Naim
‎2006 May 31 7:55 AM
u can select everything into one internal table n then segregate them
chk this code :
select from tab1 to itab.( itab contains only one field for numa & numb )
loop at itab .
move-corresponding itab to itab1.
if tab1 = '001'.
itab1-numa = itab-tab1.
clear itab1-numb.
elseif tab1 = '0001'.
itab-numb = itab-tab1.
clear itab1-numa.
endif.
append itab1.
endloop.
this shud work
Message was edited by: Bikash Agarwal
‎2006 May 31 7:55 AM
u can select everything into one internal table n then segregate them
chk this code :
select from tab1 to itab.( itab contains only one field for numa & numb )
loop at itab .
move-corresponding itab to itab1.
if tab1 = '001'.
itab1-numa = itab-tab1.
clear itab1-numb.
elseif tab1 = '0001'.
itab-numb = itab-tab1.
clear itab1-numa.
endif.
append itab1.
endloop.
this shud work
Message was edited by: Bikash Agarwal
‎2006 May 31 8:10 AM
thanx bikash and thomas..
for your valuable reply.
here i dont know the excat sequence of numbers
i know this is numa should have 3 charecter only and numb should have 4 charecters so from the colum number i need to check as it is one column only and has different values :
0001
002
0005
004
so all the values wich are in lenght of three charecters should be goes to numa and the value whic are in lenght of 4 charecters should be goes to numb...
i cant set values statically.... that is the problem
regards,
Naim
‎2006 May 31 8:47 AM
Hi Naim,
in that case, for my previous reply,
in the where condition u can use..
if strlen(tab1) = '4'.
move to numb
elseif strlen(tab1) = '3'.
move to numa.
endif.
‎2006 May 31 7:58 AM
If I understood your problem properly, you have two internal tables and from one you want to move values to another base on some conditions. For that you can make use of control break statments in internal table.
Loop the itab1.
on change of itab1-number.
case itab1-number
when'001'.
Do the logic for '001'.
when '0001'.
Do the logic for '0001'.
ENDCASE.
end of change
ENDLOOP.
Believe this will help you...
Cheers,
Thomas.
‎2006 May 31 8:05 AM
Hi Naim,
data : Itab2 like table of tab1 with header line.
data : begin of itab1,
--
---
numa(10) type c,
numb(10) type c,
end of itab1.
select * from tab1 into table itab2 where condition.
loop at itab2.
move corresponding itab2 to itab1.
if itab2-number = '001'.
move itab2-number to itab1-numa
elseif itab2-number = '0001'.
move itab2-number to itab1-numb.
endif.
append itab2.
endloop.
This will work if number, num1 and num2 are character fields only.
Regards,
Susmitha
‎2006 May 31 8:17 AM
Hi,
what u can do is check the lenth
lit_data_tab.
lit_data_3
lit_data_4.
lv_char3 type char3.
lv_char4 type char4.
lv_length type i.
loop at lit_data_tab.
lv_length = STRLEN ( lit_data_tab-value ).
if lv_length = 3.
lv_char3 = lit_data_tab-value .
append lv_char3 to lv_char3 type char3.
else.
lv_char4 = lit_data_tab-value .
append lv_char4 to lv_char3 type char4.
endif.
endloop.
if u want
numa numb
003 0003.
then u have to loop in one table and modify other.
that is any one table should contains both the field.
read the table with one field
mark helpfull answers
Regards
Message was edited by: Manoj Gupta