Skip to Content
author's profile photo Former Member
Former Member

Coding to extract last characters

Hi experts

There is a transformation from DSO_1 to DSO_2.

DSO_1 has an InfoObject CO_ITEMTX which contains text information for CO items, e.g.:

*DBD_G004 7026592.00 ABC-DE


DSO_2 needs the last char after the last space of this text information, in our example: ABC-DE.

The length of the last char can vary, e.g.:

*ABD_G004 7026552.00 ABCX-DDE

What is the correct coding?

Thanks

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    Posted on Mar 26, 2015 at 09:10 AM

    Hi Thomas,

    you can split the text at space character using the SPLIT statement.

    SPLIT <result_fields>-CO_ITEMTX AT SPACE INTO dummy1 dummy2 var_field.

    The var_field contains the value you're looking for. This works if you know the text has three section and the information you need is in the last section.

    Regards,

    Gabriele

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      problem solved, thanks.

      SELECT * FROM /BI0/SCFM_FLO_TP
      INTO table lt_POSTXT_1.
      SELECT * FROM /BI0/SCFM_SEC_ID
      INTO table lt_POSTXT_2.
      SELECT * FROM /BI0/SCFM_SEC_AC
      INTO table lt_POSTXT_3.

      IF RESULT_PACKAGE[] IS NOT INITIAL.
      ICOUNT = 1.
      REFRESH ITAB.

      SELECT * FROM /BIC/SCO_ITEMTX INTO TABLE ITAB
      FOR ALL ENTRIES IN RESULT_PACKAGE WHERE
      /BIC/CO_ITEMTX EQ RESULT_PACKAGE-/BIC/CO_ITEMTX.

      SORT ITAB BY /BIC/CO_ITEMTX.
      REFRESH ITAB_TARGET.

      SORT RESULT_PACKAGE BY /BIC/CO_ITEMTX.

      LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.
      LOOP AT ITAB INTO WA
      WHERE /BIC/CO_ITEMTX = <RESULT_FIELDS>-/BIC/CO_ITEMTX.
      IF SY-SUBRC = 0.
      SPLIT <RESULT_FIELDS>-/BIC/CO_ITEMTX at SPACE into
      V_POSTXT_1
      V_POSTXT_2 V_POSTXT_3.


      ******************************************************
      * check for existency of entry in table *
      ******************************************************

      read table lt_postxt_1 into l_postxt_1 with key CFM_FLO_TP =
      V_POSTXT_1+1.
      if sy-subrc = 0.

      <RESULT_FIELDS>-CFM_FLO_TP = V_POSTXT_1+1.

      read table lt_postxt_2 into l_postxt_2 with key CFM_SEC_ID
      =
      V_POSTXT_2.
      if sy-subrc = 0.

      <RESULT_FIELDS>-CFM_SEC_ID = V_POSTXT_2.

      read table lt_postxt_3 into l_postxt_3 with key
      CFM_SEC_AC =
      V_POSTXT_3.
      if sy-subrc = 0.

      <RESULT_FIELDS>-CFM_SEC_AC = V_POSTXT_3.

      APPEND <RESULT_FIELDS> TO ITAB_TARGET.
      ENDIF.
      ENDIF.
      ENDIF.
      ENDIF.
      ENDLOOP.
      ENDLOOP.

      SORT ITAB_TARGET BY /BIC/CO_ITEMTX.
      REFRESH RESULT_PACKAGE.
      RESULT_PACKAGE[] = ITAB_TARGET[].
      ENDIF.

  • Posted on Mar 26, 2015 at 09:08 AM

    I guess you need to use "split"... check the Help on it to understand how this can help you.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

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 you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.