0% found this document useful (0 votes)
160 views3 pages

ABAP Command "SPLIT"

The document discusses using the ABAP SPLIT command to separate a value containing an underscore into two separate values. The original code was not working correctly. An expert responded that the code was missing a loop to iterate over the RESULT_PACKAGE table. The expert also noted that the fields being split into must have constants assigned. The code was updated with the missing loop and with escaping the underscore in the LIKE condition since it is a special character in SQL.

Uploaded by

Ravindra Babu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
160 views3 pages

ABAP Command "SPLIT"

The document discusses using the ABAP SPLIT command to separate a value containing an underscore into two separate values. The original code was not working correctly. An expert responded that the code was missing a loop to iterate over the RESULT_PACKAGE table. The expert also noted that the fields being split into must have constants assigned. The code was updated with the missing loop and with escaping the underscore in the LIKE condition since it is a special character in SQL.

Uploaded by

Ravindra Babu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ABAP command "SPLIT"

Thomas Fabian 871 posts since 2 Sep, 2011


ABAP command "SPLIT" 11 May, 2015 2:59 PM
Hi ABAP experts
Question to "SPLIT" and "AT" commands:
We need to separate a value with "_" (underline) into two values, feeded to two new fields.
Is the coding below correct?
Currently it doesn't work.
Thanks!
*SELECT statement*
SELECT FC_OPBEL /BIC/ZXBLNR FROM /BIC/AZFC_DS0500
INTO CORRESPONDING FIELDS OF TABLE ITAB
FOR ALL ENTRIES IN RESULT_PACKAGE WHERE
FC_OPBEL EQ RESULT_PACKAGE-FC_OPBEL AND
/BIC/ZXBLNR LIKE '%_%'.
*READ statement in LOOP*
READ TABLE ITAB INTO WA1 WITH TABLE KEY
FC_OPBEL = <RESULT_FIELDS>-FC_OPBEL.
IF SY-SUBRC = 0.
SPLIT WA-/BIC/ZXBLNR at '_' into
V_POSTXT_1 V_POSTXT_2.
<RESULT_FIELDS>-/BIC/ZNOCORPS = V_POSTXT_1+2.
<RESULT_FIELDS>-/BIC/ZNOGRILLE = V_POSTXT_2.
ENDIF.

Ondrej Vach 269 posts since 3 Apr, 2007


Re: ABAP command "SPLIT" 11 May, 2015 3:16 PM
Hello Thomas,

Generated by Jive on 2015-09-02+02:00


1

ABAP command "SPLIT"

/BIC/ZNOCORPS and /BIC/ZNOGRILLE must have some kind of rule assigned for this code to work (at least
constant)
Also I don't see the loop over RESULT_PACKAGE.
LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.
*READ statement in LOOP*
READ TABLE ITAB INTO WA1 WITH TABLE KEY
FC_OPBEL = <RESULT_FIELDS>-FC_OPBEL.
IF SY-SUBRC = 0.
SPLIT WA-/BIC/ZXBLNR at '_' into
V_POSTXT_1 V_POSTXT_2.
<RESULT_FIELDS>-/BIC/ZNOCORPS = V_POSTXT_1+2.
<RESULT_FIELDS>-/BIC/ZNOGRILLE = V_POSTXT_2.
ENDIF.
ENDLOOP.
BR
Ondrej

Thomas Fabian 871 posts since 2 Sep, 2011


Re: ABAP command "SPLIT" 11 May, 2015 3:45 PM
Problem solved, correct coding for the select statement:

SELECT FC_OPBEL /BIC/ZXBLNR FROM /BIC/AZFC_DS0500


INTO CORRESPONDING FIELDS OF TABLE ITAB
FOR ALL ENTRIES IN RESULT_PACKAGE WHERE
FC_OPBEL EQ RESULT_PACKAGE-FC_OPBEL AND
/BIC/ZXBLNR LIKE '#_#'.

Underline is an SQL standard sign, it must be "escaped" by #.

Loed Despuig 1,946 posts since 28 Jun, 2012

Generated by Jive on 2015-09-02+02:00


2

ABAP command "SPLIT"

Re: ABAP command "SPLIT" 12 May, 2015 7:07 AM


Hi Thomas,
You may now mark your thread as ANSWERED..Just click the CORRECT ANSWER..
Regards,
Loed

Thomas Fabian 871 posts since 2 Sep, 2011


Re: ABAP command "SPLIT" 13 May, 2015 6:41 AM
My writing was incorrect, here is the correct coding, after a SELECT:

IF <RESULT_FIELDS>-/BIC/ZXBLNR CP '*_*'.
SPLIT <RESULT_FIELDS>-/BIC/ZXBLNR AT '_' INTO V_POSTXT_1
V_POSTXT_2.
<RESULT_FIELDS>-/BIC/ZNOCORPS = V_POSTXT_1+2.
<RESULT_FIELDS>-/BIC/ZNOGRILLE = V_POSTXT_2.
ENDIF.

Generated by Jive on 2015-09-02+02:00


3

You might also like