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: 

Need to print the last four character of a field

Former Member
0 Kudos

Hi,

I need to print the last and the first 10 for character of a field.

like the field name is mara-wrkst.i need to print last 4 and first 10.

5 REPLIES 5

Former Member
0 Kudos

Hi

For the first ten it will be

DATA: ws_first type char10.

ws_first = mara-wrkst+0(10)

Former Member
0 Kudos

Hi

You can do that by using offset.

Eg:

l_var(10) -> first 10 characters

l_var+6(4) -> last 4 characters from a field of 10 chars.

Kind Regards

Eswar

andreas_mann3
Active Contributor
0 Kudos

Hi,

last 4:

z = strlen ( mara-wrkst ) - 4.

if z > 10."1st condition 1st 10
 write mara-wrkst+Z(4).
endif.

A.

Message was edited by: Andreas Mann

Former Member
0 Kudos

HI Kamlesh,

find the sample code below. This should solve your issue.

DATA: wrkst TYPE wrkst VALUE '20061010565656556',

ws_wrkst TYPE wrkst,

wrkst1 TYPE char10,

wrkst2 TYPE char4.

WRITE wrkst TO ws_wrkst RIGHT-JUSTIFIED.

wrkst1 = ws_wrkst+44(4).

clear ws_wrkst.

WRITE wrkst TO ws_wrkst left-JUSTIFIED.

wrkst2 = ws_wrkst+0(10).

write: wrkst1 , wrkst2.

Reward points if this helps.

Manish

Former Member
0 Kudos

hi

good

store that value in a field and split the value in two and store in two variables and than you print them.

Use the SPLIT statement

thanks

mrutyun^