cancel
Showing results for 
Search instead for 
Did you mean: 

End Routine - populating Target Field based on Master Data

Former Member
0 Kudos

Hi,

I have an issue with my End Routine in BI 7.0. The scenario is as follows....

The Target-Fields ZSALES_OFFICE , 0SALES_CHANNEL etc. are being mapped 1:1 from their respective source fields. In addition to these target fields I have a target field 0SALESORG which I need to populate based on the values from 0COMP_CODE which is an attribute of ZSALES_OFFICE. The values of 0COMP_CODE are 9000, 9001, 9002 and 9003 respectively. The end routine condition needs to be implemented as follows...

For every 0COMP_CODE which has value 9000, 0SALESORG should be populated with the value "EAST". Similarly for every 0COMP_CODE which has value 9001, 0SALESORG should be populated with the value "WEST", for every 0COMP_CODE which has value 9002, 0SALESORG should be populated with the value "NORTH" and for every 0COMP_CODE which has value 9003, 0SALESORG should be populated with the value "SOUTH". I tried the following code but it doesnt seem to work. Could you pls help!!

Thanks,

SD

DATA: it_tab4 TYPE TABLE OF /BIC/PZF31SALOFF,

wa_tab4 TYPE /BIC/PZF31SALOFF.

SELECT *

FROM /BIC/PZF31SALOFF

INTO CORRESPONDING FIELDS OF TABLE it_tab4.

sort it_tab4 by /BIC/ZF31SALOFF.

LOOP AT RESULT_PACKAGE

INTO <result_fields>.

read table it_tab4

with key /BIC/ZF31SALOFF = <result_fields>-/BIC/ZF31SALOFF

into wa_tab4

binary search.

if sy-subrc eq 0.

CASE wa_tab4-comp_code.

WHEN '9000'.

<result_fields>-salesorg = 'EAST'.

WHEN '9100'.

<result_fields>-salesorg = 'WEST'.

WHEN '9200'.

<result_fields>-salesorg = 'NORTH'.

WHEN '9300'.

<result_fields>-salesorg = 'SOUTH'.

MODIFY it_tab4 FROM wa_tab4.

ENDCASE.

endif.

ENDLOOP.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Change the loop statement

from:

LOOP AT RESULT_PACKAGE

INTO <result_fields>.

to :

LOOP AT RESULT_PACKAGE

ASSIGINING <result_fields>.

Former Member
0 Kudos

Hello Priyadarshini,

Thanks a lot for ur suggestion!! My routine now works perfect.

Since I am a beginner in ABAP I would like to know if I could optimize my code in any way. As per the previous comments is it redundant to declare 2 tables i.e. Internal table and work area table. Pls advise.

Thanks,

SD

Answers (3)

Answers (3)

Former Member
0 Kudos

Replace your select statement ,

SELECT *

FROM /BIC/PZF31SALOFF

INTO CORRESPONDING FIELDS OF TABLE it_tab4.

instead of selecting all the fields , pick only the fields which are required.(one good performance improvement)

SELECT /BIC/PZF31SALOFF comp_code

FROM /BIC/PZF31SALOFF

INTO CORRESPONDING FIELDS OF TABLE it_tab4.

Remove the line below , this is not required

MODIFY it_tab4 FROM wa_tab4.

Former Member
0 Kudos

ok, will do so. Thanks again!!

Former Member
0 Kudos

use field list instead of select *

and fetch only filed that is required for your processing. In your case it is two fields.

secondly i donot get why you are modifying itab4 from wa_tab4....it is redundant statement.

Former Member
0 Kudos

did you do debug?

I think the select statement is incorrect

SELECT *

FROM /BIC/PZF31SALOFF

INTO CORRESPONDING FIELDS OF TABLE it_tab4.

Please check if the table it_tab4 is getting filled correctly