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

ABAP Case Statement in Transformation End Routine


Hi,

I am writing the below Start and end routine with a case statement but some reason its not working as expected.....With my limited ABAP knowledge I could able to correct the issue ...

Shall be grateful if someone could provide me inputs.


Logic: A Z Table is maintained with company code and default Profit Centre.

For all Profit centres from source we need to check if first 2 letters starts with IE and source company code 531 0r 521 then populate source fields to result fields if not then populate from z table

Start Routine

SELECT * FROM ZCC_PC_MAPPING INTO TABLE t_cc_pc_map FOR ALL ENTRIES IN SOURCE_PACKAGE
WHERE COMP_CODE = SOURCE_PACKAGE-COMP_CODE.
SORT t_cc_pc_map BY comp_code.

End Routine:

LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.

l_prefix = <RESULT_FIELDS>-PROFIT_CTR(2).

CASE l_prefix.
WHEN 'IE'.
IF <RESULT_FIELDS>-COMP_CODE = '531' OR
<RESULT_FIELDS>-COMP_CODE = '521'.
<RESULT_FIELDS>-PROFIT_CTR = <RESULT_FIELDS>-PROFIT_CTR.
<RESULT_FIELDS>-CO_AREA = <RESULT_FIELDS>-CO_AREA.
ENDIF.
WHEN 'CY'.
IF <RESULT_FIELDS>-COMP_CODE = '797' OR
<RESULT_FIELDS>-COMP_CODE = '993' OR
<RESULT_FIELDS>-COMP_CODE = '994'.
<RESULT_FIELDS>-PROFIT_CTR = <RESULT_FIELDS>-PROFIT_CTR.
<RESULT_FIELDS>-CO_AREA = <RESULT_FIELDS>-CO_AREA.
ENDIF.
WHEN 'RW'.
IF <RESULT_FIELDS>-COMP_CODE = '1004' OR
<RESULT_FIELDS>-COMP_CODE = '650' OR
<RESULT_FIELDS>-COMP_CODE = '911'.
<RESULT_FIELDS>-PROFIT_CTR = <RESULT_FIELDS>-PROFIT_CTR.
<RESULT_FIELDS>-CO_AREA = <RESULT_FIELDS>-CO_AREA.
ENDIF.
WHEN 'NZ'.
IF <RESULT_FIELDS>-COMP_CODE = '1029'.
<RESULT_FIELDS>-PROFIT_CTR = <RESULT_FIELDS>-PROFIT_CTR.
<RESULT_FIELDS>-CO_AREA = <RESULT_FIELDS>-CO_AREA.
ENDIF.
WHEN 'GB'.
IF <RESULT_FIELDS>-COMP_CODE <> ' '.
<RESULT_FIELDS>-PROFIT_CTR = <RESULT_FIELDS>-PROFIT_CTR.
<RESULT_FIELDS>-CO_AREA = <RESULT_FIELDS>-CO_AREA.
ENDIF.
WHEN 'GS'.
IF <RESULT_FIELDS>-COMP_CODE <> ' '.
<RESULT_FIELDS>-PROFIT_CTR = <RESULT_FIELDS>-PROFIT_CTR.
<RESULT_FIELDS>-CO_AREA = <RESULT_FIELDS>-CO_AREA.
ENDIF.
* WHEN 'GB' OR 'IE' OR 'NZ' OR 'CY' OR 'RW' OR 'GS'.
* CONTINUE.
WHEN OTHERS.
READ TABLE t_cc_pc_map ASSIGNING <fs_cc_pc_map>
WITH KEY comp_code = <RESULT_FIELDS>-COMP_CODE BINARY SEARCH.

IF sy-subrc = 0.
<RESULT_FIELDS>-PROFIT_CTR = <fs_cc_pc_map>-profit_c.
<RESULT_FIELDS>-CO_AREA = <fs_cc_pc_map>-co_area.
ENDIF.
ENDCASE.
ENDLOOP.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on May 19, 2015 at 06:18 PM

    Hi,

    Please use below clear statement before assigning new value.

    Maintain below line after LOOP statement and the assign new value.

    Clear : l_prefix.

    Thank you,

    Nanda

    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.