cancel
Showing results for 
Search instead for 
Did you mean: 

Coding to extract last characters

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

gabrielenosatti
Explorer
0 Kudos

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

Former Member
0 Kudos

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.

Answers (1)

Answers (1)

RafkeMagic
Active Contributor
0 Kudos

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