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: 

about report program

Former Member
0 Kudos

how can I get last character from a field of type char(12)?

in this field it may possible that it have only 3 char(ie. 'abc').

and how can append a character in the end of field(char 12)of data base table.

in this field it may possible that it have only 3 char(ie. 'abc').

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Anutosh

Capturing the last charecter can be done by either right-justifying he field and then taking the last char or by measuring the length of the string and then take offset accordingly.

Coming to the second part of your question (how can append a character in the end of field(char 12)of data base table?) once you get the length of the existing string say 3 char long ('ABC'). now add a new char at 12th position in the string if you want it in the end or at the strlen(string lenght) position if you want it immediately after your actual string.

Regards

Santosh

6 REPLIES 6

Former Member
0 Kudos

see if this is what you are looking for...

REPORT yytest88 LINE-COUNT 20 NO STANDARD PAGE HEADING.

parameters : p_scr1(12) obligatory default 'ABC'.

data : wa_test(12) value ' X'.

overlay p_scr1 with wa_test.

write 😕 p_scr1.

Former Member
0 Kudos

Hi

DATA: STRING(12) TYPE C VALUE 'ABC',

WA LIKE STRING.

DATA: LEN TYPE I.

  • Calculate how many positions are filled:

LEN = STRLEN( STRING ).

WRITE STRING(LEN) TO WA RIGHT-JUSTIFIED.

STRING = WA.

Max

Former Member
0 Kudos

Hi ,

how can I get last character from a field of type char(12)?

in this field it may possible that it have only 3 char(ie. 'abc').

DATA : STR_LENGTH TYPE SY-TABIX,

V_OFF_SET TYPE SY-TABIX.

STR_LENGTH = STRLEN( Field ).

V_OFF_SET = STR_LENGTH - 1.

Field1 = Field+V_OFF_SET(STR_LENGTH ).

Lanka

Former Member
0 Kudos

Hi Anutosh,

For your frist question move the field towards right side using 'RIGHT-JUSTIFIED' and take the offset of the field.

Former Member
0 Kudos

Hi Anutosh,

Try this..

DATA: V_FLD(10) VALUE 'ASD',

V_LEN TYPE I,

V_LEN1 TYPE I,

V_TEXT.

V_LEN = STRLEN( V_FLD ).

V_LEN1 = V_LEN - 1.

V_TEXT = V_FLD+V_LEN1(V_LEN).

WRITE:/ V_TEXT.

Former Member
0 Kudos

Hi Anutosh

Capturing the last charecter can be done by either right-justifying he field and then taking the last char or by measuring the length of the string and then take offset accordingly.

Coming to the second part of your question (how can append a character in the end of field(char 12)of data base table?) once you get the length of the existing string say 3 char long ('ABC'). now add a new char at 12th position in the string if you want it in the end or at the strlen(string lenght) position if you want it immediately after your actual string.

Regards

Santosh