2006 Feb 16 5:24 PM
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').
2006 Feb 16 6:12 PM
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
2006 Feb 16 5:27 PM
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.
2006 Feb 16 5:32 PM
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
2006 Feb 16 5:32 PM
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
2006 Feb 16 5:34 PM
Hi Anutosh,
For your frist question move the field towards right side using 'RIGHT-JUSTIFIED' and take the offset of the field.
2006 Feb 16 5:43 PM
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.
2006 Feb 16 6:12 PM
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