03-25-2008 5:48 AM
Hello experts:
Thank you in advance for all your replies.
take a look at the following program, could you please tell me how 12 in SY-TVAR0+12(3) works , it couldn't be better if you can explain it by examples. couldn't thank you more.
Best regards.
Frank
**********************************
REPORT ZPRACTISE.
data: g7(3) type n,
PR TYPE I,
tx_it1(36),
fkimg type p decimals 3.
fkimg = 2480 .
SY-TVAR0 = fkimg.
g7 = SY-TVAR0+12(3).
write : / g7.
03-25-2008 6:33 AM
Hi,
This is an offsetting technique. Offsetting is fit for certain data types.The following sample code will give you some perception regarding the offsetting technique.
Note : use debug mode.
data : date like sy-datum,
var(10).
start-of-selection.
concatenate date6(2) '.' date4(2) '.' date+0(4) into var.
end-of-selection.
write : /1 var.
Reward if useful.
Regards,
Sankar.
03-25-2008 5:53 AM
This is calles as offsetting. 12 is the positiona dn 3 is the number of char to be extracted.
eg. g_text = 'SAPABAP'.
g_text4(4) will be ABAP.
03-25-2008 6:29 AM
Hello Barath Srinivas,
let me correct your statement:
when g_text = 'SAPABAP1'.
g_text+4(4) is NOT "ABAP" but "BAP1"! +4 is the 5th position in the string.
In your case g_text+4(4) (with the value SAPABAP) causes a dump because your field does have only the length of 7.
Heinz
03-25-2008 5:58 AM
HI,
fkimg is a pack type field.so while assigning it to sy-tvar0(Text Variable for Placeholders in List Headers)
then it will be assigned as 000000000002480.000
so sy-tvar0+12(3) = 480.
rgds,
bharat.
03-25-2008 6:17 AM
Hello dongdong,
SY-TVAR0 is a 20 Char field.
fkimg contains the value 2480.000. After moving fkimg to the character string, SY-TVAR0 looks like (in ASCII): "2020202020202020202020323438302E30303020".
g7 = SY-TVAR0+12(3) selects the 13th byte of SY-TVAR0 in the length of 3, i.e. the value of g7 is "343830" or 480.
I hope this helps,
Heinz
03-25-2008 6:33 AM
Hi,
This is an offsetting technique. Offsetting is fit for certain data types.The following sample code will give you some perception regarding the offsetting technique.
Note : use debug mode.
data : date like sy-datum,
var(10).
start-of-selection.
concatenate date6(2) '.' date4(2) '.' date+0(4) into var.
end-of-selection.
write : /1 var.
Reward if useful.
Regards,
Sankar.
03-25-2008 6:44 AM
the length of variable SY-TVAR0 is 20 and it is right justified.
so when you fkimg to SY-TVAR0, the value in the variable fkimg(2480) is rigt justified to SY-TVAR0 and padded with spaces on the left side.
when you use g7 = SY-TVAR0+12(3), this will retrieve 3 chars from left starting from 12th posiion.
rewards if useful............
03-25-2008 7:09 AM
Hi,
Pls refer below statements,
fkimg = 2480 .
Now fkimg is 2480.000
SY-TVAR0 = fkimg.
SY-TVAR0 has 20 char.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
+2 4 8 0 . 0 0 0 /-
so at 12th position 4 is stored. so while using the offset
12(3) u will get 480.
Reward points if it is useful
regards,
vijay