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

End Routine in Transformation

Hi Everyone,

Anyone that can assist me with my end routine code? You will notice in the source screenshot there are records against 0STKEYFIG 'CS149' & 'CS158'. What I want to achieve is where the material and creditor fields against cs158 matches the material creditor fields against cs149, to populate 0value_lc against cs149 records using 0value_lc value from cs158, as shown in destination screenshot.

Attached is also the source code of my end routine, but it is not working.

Thanks guru's, any assistance would be appreciated.

Best Regards,

Rudi

Source:

Destination:

dest.PNG (12.8 kB)
example.PNG (15.7 kB)
Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    Posted on Dec 05, 2015 at 10:36 AM

    Hello Rudi,

    use either of below approach...

    APPROACH--> 1

    FIELD-SYMBOLS:<RESULT_FIELDS_1> TYPE _ty_s_TG_1.

    data: IT_RESULT_PACKAGE TYPE STNADARD TABLE OF _ty_s_TG_1,

    lv_index type sy-index.

    IT_RESULT_PACKAGE[] = RESULT_PACKAGE[].

    DELETE RESULT_PACKAGE WHERE stkeyfig = 'cs149' .

    DELETE RESULT_PACKAGE WHERE stkeyfig = 'cs158' .

    DELETE IT_RESULT_PACKAGE WHERE stkeyfig <> 'cs149'

    OR stkeyfig <> 'cs158'.

    SORT it_result_package by CREDITOR MATERIAL acending STKEYFIG decending.

    lv_index = 0.

    LOOP AT it_result_package ASSIGNING <result_fields> FROM lv_index

    WHERE <result_fields>-stkeyfig = 'CS158' .

    lv_index = sy-index + 1 .

    LOOP AT it_result_package ASSIGNING <result_fields_1> FROM lv_index.

    IF <result_fields_1>-stkeyfig = 'CS149' AND

    <result_fields_1>-CREDITOR = <result_fields>-CREDITOR AND

    <result_fields_1>-MATERIAL = <result_fields>-MATERIAL.

    <result_fields_1>-VALUE_LC = <result_fields>-VALUE_LC .

    ELSE.

    <result_fields_1>-VALUE_LC = 0.

    exit.

    ENDIF.

    ENDLOOP.

    lv_index = sy_index.

    ENDLOOP.

    APEEND LINES OF it_result_package TO table RESULT_PACKAGE.

    CLEAR : it_result_package.

    ----------------------------------------------------------------------------

    APPROACH--> 2

    DATA : RESULT_PACKAGE_CS149 TYPE STNADARD TABLE OF _ty_s_TG_1,

    RESULT_PACKAGE_CS158 TYPE STNADARD TABLE OF _ty_s_TG_1.

    FIELD-SYMBOLS:<RESULT_FIELDS_CS149> TYPE _ty_s_TG_1,

    <RESULT_FIELDS_CS158> TYPE _ty_s_TG_1.

    IT_RESULT_PACKAGE_CS149[] = RESULT_PACKAGE[].

    IT_RESULT_PACKAGE_CS158[] = RESULT_PACKAGE[].

    DELETE RESULT_PACKAGE WHERE stkeyfig = 'cs149'.

    DELETE RESULT_PACKAGE WHERE stkeyfig = 'cs158'.

    DELETE RESULT_PACKAGE_CS149 WHERE stkeyfig <> 'cs149'.

    DELETE RESULT_PACKAGE_CS158 WHERE stkeyfig <> 'cs158'.

    SORT RESULT_PACKAGE_CS158 BY CREDITOR MATERIAL.

    LOOP AT RESULT_PACKAGE_CS149 ASSIGNING <RESULT_FIELDS_CS149>.

    READ TABLE RESULT_PACKAGE_CS158 ASSIGNING <RESULT_FIELDS_CS158>

    WITH KEY <RESULT_FIELDS_CS158>-CREDITOR = <RESULT_FIELDS_CS149>-CREDITOR

    <RESULT_FIELDS_CS158>-MATERIAL = <RESULT_FIELDS_CS149>-MATERIAL BINARY SEARCH.

    IF sy-subrc = 0 .

    <RESULT_FIELDS_CS149>-VALUE_LC = <RESULT_FIELDS_CS158>-VALUE_LC.

    ENDIF.

    ENDLOOP.

    APPEND LINES OF RESULT_PACKAGE_CS149 TO RESULT_PACKAGE.

    APPEND LINES OF RESULT_PACKAGE_CS149 TO RESULT_PACKAGE.

    FREE: RESULT_PACKAGE_CS149[] , RESULT_PACKAGE_CS158[].

    ----------------------------------------------------------------------------------------------------------------

    NOTE: For either approch u need to set Semantic grouping @ DTP Level on Fields : CREDITOR & MATERIAL.

    for approach 2 u may required nothing to change.. but i will suggest approach 1 for performance (may require little chnages).....

    Regards,

    Hitesh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 10, 2015 at 09:30 AM

    Thanks Amit and Hitesh, with some modifications your method worked Hitesh... much appreciated.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 04, 2015 at 11:04 AM

    Hi,

    What exactly you mean by not working ?

    Can you share a screenshot of the output using your end routine like how is the data populated presently?

    Regards,

    Amit

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Amit Sharma

      Thanks Amit for the response..

      Create two internal tables itab1,itab2 of type result_package

      Obviously my abap skills is dull, but this is the part I struggle with... and somehow just can not get it declared correctly. When I think the internal table is created, I get the error "x is neither specified under "TABLES" nor is it defined as an internal table" when I try to loop through it...

      Hehe, I am so glad its Friday as my frustration is note able due to my lack of knowledge in this language...

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.