on 02-09-2016 6:49 AM
Hi All,
I have a requirement where in i need to put add one more column for material, which will be fetched based on 2 Condition against Doc Number and material no
basically i have to sort the mat doc Num and look for corresponding History Cat = E and Movement Type 101 and select the adjacent Material No and fill it to new Column with same matnr
So to achieve this I have added new Infobject and need to write the End Routine
can anyone help with the Code.?
Refer Screenshot for details
Hi,
You may try to implement in END ROUTINE any of the codes below..
Assuming that letter "E" is the lowest HCT value, you may use this..
DATA: temp_zfmatrl TYPE zfmatrl.
SORT result_package BY material_doc ASCENDING hct ASCENDING mvt ASCENDING.
LOOP AT result_package ASSIGNING <result_fields>.
AT NEW material_doc.
temp_zfmatrl = <result_fields>-material.
ENDAT.
<result_fields>-zfmatrl = temp_zfmatrl.
ENDLOOP.
If there are other HCT values lower than "E" (since I used ASCENDING), just use this..
DATA: wa_result_pack TYPE _ty_s_tg_1.
LOOP AT result_package ASSIGNING <result_fields>.
READ TABLE result_package INTO wa_result_pack
WITH KEY
hct = 'E'
mvt = '101'
material_doc = <result_fields>-material_doc.
IF sy-subrc = 0.
<result_fields>-zfmatrl = wa_result_pack-material.
ENDIF.
CLEAR wa_result_pack.
ENDLOOP.
Just replace them with the correct data types..
Regards,
Loed
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
What code did you use?
Try to use this:
DATA: wa_result_pack TYPE _ty_s_tg_1.
SORT result_package BY material_doc ASCENDING hct ASCENDING mvt ASCENDING.
LOOP AT result_package ASSIGNING <result_fields>.
READ TABLE result_package INTO wa_result_pack
WITH KEY
hct = 'E'
mvt = '101'
material_doc = <result_fields>-material_doc
binary-search.
IF sy-subrc = 0.
<result_fields>-zfmatrl = wa_result_pack-material.
ENDIF.
ENDLOOP.
Regards,
Loed
DATA: wa_result_pack TYPE _ty_s_tg_1.
SORT RESULT_PACKAGE by DOC_NUM ASCENDING /BIC/ZBEWTP ASCENDING
MOVETYPE.
LOOP AT RESULT_PACKAGE ASSIGNING <result_fields>.
READ TABLE RESULT_PACKAGE INTO wa_result_pack
WITH KEY
/BIC/ZBEWTP = 'E'
MOVETYPE = '101'
DOC_NUM = <result_fields>-DOC_NUM.
IF sy-subrc = 0.
<result_fields>-/BIC/ZFMATNR = wa_result_pack-MATERIAL.
ENDIF.
CLEAR wa_result_pack.
ENDLOOP.
Dear,
Store your result_package in temp table say RESULT_TEMP..then
move RESULT_PACKAGE[] to RESULT_TEMP[]....then
Sort RESULT_TEMP by Material doc Hct Mvt.....then
Loop at result_package assigning <result_fields>.
read table RESULT_TEMP into <result_fields_temp> with key material doc = <result_fields>-material doc Hct = 'E' Mvt = '101' Binary Search.
If sy-subrc = 0.
move <result_fields_temp>-material to <result_fields>-ZFMATRL.
endif.
Endloop.
Thanks & Regards,
M
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would start by filling an internal table with all the lines for combination Hct = E & Mvt = 101 (either in start or end routine).
In the end routine, you'll read this table for each line where Hct <> E & Mvt <> 101 to find the corresponding value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.