cancel
Showing results for 
Search instead for 
Did you mean: 

how to split xstring not having an identifier

anvesh_kumar3
Explorer
0 Kudos

Hi,

How to split an xstring in SAP ABAP based on totally on size and the string does not have an identifier to judge the position to break.

Please help if you know some solution. Thanks!

Best Regards

Anvesh Kumar

Osapiens service gmbH

germany

Sandra_Rossi
Active Contributor

To split on what basis?

matt
Active Contributor
0 Kudos

Hint. Exactly as you would a string.

Marissa
Advisor
Advisor
0 Kudos

We helped you to accept the answer, since there were no updates after 7 days.

You can unaccept it anytime if you have further questions.

Accepted Solutions (1)

Accepted Solutions (1)

anvesh_kumar3
Explorer
0 Kudos

Based on byte size. If the xstring is 4 MB , I want to split it in 2 portion of 2-2 MB. Thanks!

matt
Active Contributor

Don't add an answer when you should comment. It even says right next to the answer box:

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that your answer complies with our Rules of Engagement.

anvesh_kumar3
Explorer
0 Kudos

Hi Matthew,

Thanks for the input. I am new to this community and didn't actually realize that there us a "Add a comment" button. Sorry!

Answers (1)

Answers (1)

Sandra_Rossi
Active Contributor
0 Kudos
CLASS lcl_app DEFINITION.
PUBLIC SECTION.
CLASS-METHODS split_xsequence
IMPORTING
xsequence TYPE xsequence
width TYPE i
RETURNING
VALUE(result) TYPE xstring_table.
ENDCLASS.
CLASS lcl_app IMPLEMENTATION.
METHOD split_xsequence.
result = VALUE #(
FOR off = 0 THEN off + width WHILE off < xstrlen( xsequence )
LET len = nmin( val1 = width val2 = xstrlen( xsequence ) - off ) IN
( CONV #( xsequence+off(len) ) ) ).
ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
DATA(xstring_table) = lcl_app=>split_xsequence( xsequence = '415152' width = 2 ).
ASSERT xstring_table = value xstring_table( ( conv #( '4151' ) ) ( conv #( '52' ) ) ).