‎2007 Feb 09 3:40 AM
Hi,
Anyone please tell me how I can code this...
I must read the value from a field QTY with data type CHAR 40 from the table zqt83.
Its value will have number+text..
Ex: 4.012 Kg G
I must show
f1 = 4.012
f2 = Kg G.
How do I do this?
‎2007 Feb 09 4:28 AM
sorry i cannot get you properly can you give some idea with sample data i.e. what is your requirement..
regards
shiba dutta
‎2007 Feb 09 3:49 AM
data : len type i,
pos type i,
v_temp,
f1(15),
f2(25).
len = strlen( str ).
do len times.
v_temp = str+pos(1).
if v_temp ca '0123456789.'.
concatenate f1 v_temp into f1.
else.
concatenate f2 v_temp into f2.
endif.
pos = pos + 1.
enddo.
here str is the qty you are reading.
regards
shiba dutta
‎2007 Feb 09 4:24 AM
Hi Shiba ,
your code is good...but in my situation ..I had some confusion because..
I must bring 4 fields f1 , f2, f3 & qty using a select statement.
Now I must devide Qty = f4 + f5
and write all the fileds together f1....f5
I was not able to do this ..as I had some confusion with the ITAB.
Please help me out of this problem
‎2007 Feb 09 4:30 AM
Select f1 f2 f3 qty
from zxxx
into corresponding fields of table itab.
If u r filling only f1 f2 and f3, otherwise into corres is not needed.
Let me know where f4 and f5 are coming?
if from itab.
LOOP AT itab.
itab-qty = itab-f4 + itab-f5.
MODIFY itab.
clear itab.
ENDLOOP.Please be more specific.
‎2007 Feb 09 4:28 AM
sorry i cannot get you properly can you give some idea with sample data i.e. what is your requirement..
regards
shiba dutta
‎2007 Feb 09 4:36 AM
Yes sure..
I am pulling data from a z table using select statement
<b>select un_no qty pname pack pclass
from zqt83 into corresponding fields of table lt_zqt83
for all entries in lt_lips
where part_no = lt_lips-matnr.</b>
Now I need to devide this qty into 2 parts and put all this data into another ITAB.My confusion was when I am trying to put it into the ITAB.
‎2007 Feb 09 4:41 AM
DATA: begin of itab occurs 0,
un_no
qty1( ) type c,
qty2(4) type c,
pname
pack
pclass
end of itab.
select un_no qty pname pack pclass
from zqt83 into corresponding fields of table lt_zqt83
for all entries in lt_lips
where part_no = lt_lips-matnr.
LOOP AT li_zqt83.
SPLIT it_zqt83-qty AT SPACE INTO
itab-qty1 itab-qty2.
itab-un_no = it_zqt83-un_no.
itab-pname = it_zqt83-pname.
itab-pack = it_zqt83-pack.
itab-pclass = it_zqt83-pclass.
APPEND itab.
clear itab.
clear it_zqt83.
ENDLOOP.
‎2007 Feb 09 4:48 AM
Thank you very much Jessie,
But my last problem is ...I can't take the unit to be started with <b>K</b>.....now how should I change this code
‎2007 Feb 09 4:53 AM
Hi,
U can code like
SPLIT it_zqt83-qty AT SPACE INTO
itab-qty1 itab-qty2.U can split at SPACE. Anyway u will be having SAPCE after the value right?
‎2007 Feb 09 5:02 AM
Yes we have a space...but I have an example of data
qty = 4.023 Kg G
I need to put like this
f4 = 4.023
f5 = Kg G
there will be 2 spaces in the second part.
Message was edited by:
ramana peddu
‎2007 Feb 09 5:09 AM
for that code
split qty at space into f1 f2 f3.
concatenate f2 f3 into f2.
now your f1 = 4.023
and f2 = Kg G.
check as per your requirement this code is only for the data you have posted.
regards
shiba dutta
‎2007 Feb 09 5:10 AM
The code which I gave you will work try that.
If u have two space also it will only get splitted at the first part.
U want K G to be in a single field right?
See the sameple code
DATA: string(20) TYPE c VALUE 'st ri ng120',
string1(10) TYPE c ,
string2(10) TYPE c .
SPLIT string AT space INTO string1 string2.
Write string2.St will be in string1 and
ri ng120 will be in string2.
Please reward points and close the thread if ur problem got solved.
‎2007 Feb 09 5:16 AM
‎2007 Feb 09 4:43 AM
try this
data : str(40) type c value '4.012 5.23 Kg G',
len type i,
pos type i,
v_temp,
f1(10),
f2(10),
f3(10),
f4(10).
split str at space into f1 f2 f3 f4.
if all the values are separated by space.
regards
shiba dutta