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: 

how to find string last 4 chars

Former Member
0 Kudos

hi,

i need to get the last 4 chars of the string with that i have to compare.

or..

in bdc i have to upload the data from flat file that may be .txt / .xls.. which FM we have to use for to upload.

any suggestions .. pl..

1 ACCEPTED SOLUTION

Former Member

Hi,

try this:

DATA: STR TYPE STRING VALUE 'testfrom2007'.

DATA: CSTR(4).

DATA: STRL TYPE I.

*

STRL = STRLEN( STR ).

IF STRL > 4.

STRL = STRL - 4.

CSTR = STR+STRL(4).

ELSE.

CSTR = STR.

ENDIF.

*

WRITE: CSTR.

regards, Dieter

8 REPLIES 8

Former Member
0 Kudos

get the string length first using strlen function

then use offset method

Former Member
0 Kudos

use

<b>gui_upload</b> to upload data from .txt/.xls files.

regards,

srinivas

<b>*reward for useful answers*</b>

Former Member
0 Kudos

Hi,

length = strlen( my_char ).

position = length - 4.

result = mychar+position.

Regards,

Mathieu

Former Member
0 Kudos

Hi,

1.

int_var = strlen( tbl-fld ).

int_var1 = int_var - 4.

result_txt = tbl-fld+int_var1(int_var).

2.

use FM GUI_UPLOAD.

Jogdand M B

amit_khare
Active Contributor
0 Kudos

Welcome to SDN.

to get last four character.

st1 = strlen( str2 ).

str1 = str1 - 4.

str3 = str2+str1(4).

Regards,

Amit

Reward all helpful replies

Former Member

Hi,

try this:

DATA: STR TYPE STRING VALUE 'testfrom2007'.

DATA: CSTR(4).

DATA: STRL TYPE I.

*

STRL = STRLEN( STR ).

IF STRL > 4.

STRL = STRL - 4.

CSTR = STR+STRL(4).

ELSE.

CSTR = STR.

ENDIF.

*

WRITE: CSTR.

regards, Dieter

Former Member
0 Kudos

Hi Satish,

To find the last 4 digits, try this code.

DATA: len TYPE i,
      str(10) TYPE c VALUE 'abcdefghij',
      substr TYPE string.

len = STRLEN( str ) - 4.

substr = str+len(4).


WRITE: / substr.

And regarding the file uploading, if you want to upload file fro the GUI Server, you can use the function module

GUI_UPLOAD

.

And if you want to upload from Application server, you can use

OPEN DATASET, READ DATASET

...

Plz reward points if useful...

Regards,

Bijesh

SuhaSaha
Advisor
Advisor
0 Kudos

Hi Satish,

DATA: V_STRING TYPE STRING,
V_LASTFOUR TYPE STRING,
V_LENGTH TYPE N.

V_LENGTH = STRLEN (V_STRING) - 4.

V_LASTFOUR = V_STRING + V_LENGTH(4)

You can use the FM 'GUI_UPLOAD' if you have the file (.txt) from the presentation server.

Please award points if helpful.

Regards,

Suhas