‎2008 Jun 17 3:00 PM
Hi,
I have a string value ' DBTABLE-FIELDNAME'. I need to split this into 2 strings - The first one is the database table name and the second one is the fieldname. So, the character '-' is the point where the split needs to be done. How can this be achieved. Any FM that I could use?
Thanks for your help!
Regards,
Divyaman Singh Rawat
‎2008 Jun 17 3:03 PM
Hi!
The answer is in your question.
Use the SPLIT command for this.
Regards
Tamá
‎2008 Jun 17 3:03 PM
Hi!
The answer is in your question.
Use the SPLIT command for this.
Regards
Tamá
‎2008 Jun 17 3:04 PM
‎2008 Jun 17 3:03 PM
there is no FM
but u can use split command.
DATA: str1 TYPE string,
str2 TYPE string,
str3 TYPE string,
text TYPE string.
text = `mara-matnr`.
SPLIT text AT '-' INTO str1 str2 .
‎2008 Jun 17 3:07 PM
Use FM 'STRING_SPLIT'
REPORT ZEXAMPLE.
DATA: V_HEAD(10), V_TAIL(10).
PARAMETERS: P_STR(20),
P_DEM.
CALL FUNCTION 'STRING_SPLIT'
EXPORTING
DELIMITER = P_DEM
STRING = P_STR
IMPORTING
HEAD = V_HEAD
TAIL = V_TAIL
EXCEPTIONS
NOT_FOUND = 1
NOT_VALID = 2
TOO_LONG = 3
TOO_SMALL = 4
OTHERS = 5.
IF SY-SUBRC EQ 0.
WRITE:/ 'HEAD:', V_HEAD,
/ 'TAIL:', V_TAIL.
ELSE.
WRITE:/ 'ERROR SPLITTING STRING'.
ENDIF.
Regards,
Joy.
‎2008 Jun 17 3:09 PM
Hi,
For this type of logic what you need to do is use CA operator ( Contains Any)
Exmaple:
DATA: ulimit type DBTABLE-FIELDNAME'. DATA: STR(10) TYPE C. DATA: LEN TYPE I. DATA: LEN1 TYPE I. DATA: TOTAL TYPE I. DATA: REMAIN TYPE I. STR = ULIMIT. CONDENSE STR. IF STR CA '-'. LEN = SY-FDPOS. LEN1 = LEN - 1. TOTAL = STRLEN( STR ). REMAIN = TOTAL - LEN. TABLE = STR+0(LEN). FIELDNAME = STR+LEN1( REMAIN ). ENDIF. WRITE:/ TABLE. WRITE:/ FLDNAME.