Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

do me a favor , mates

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

7 REPLIES 7

former_member210123
Active Participant
0 Kudos

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.

0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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............

Former Member
0 Kudos

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