Order | Material | Plant | Location | Qty | Unit | Movetype |
1000269 | 31-009924-004-R000 | 8101 | WA01 | 1 | EA | 262 |
1000269 | 31-009924-004-R000 | 8101 | WA01 | 1 | EA | 261 |
*&---------------------------------------------------------------------*
*& Progarm : ZMM_GOODS_ISSUE_262_261 Author : Jimmy Wong
*& Created : 23 Jan 2013 App : MM
*& Title : Goods Issue 262 & 261
*& Description : Goods Issue 262 & 261
*&---------------------------------------------------------------------*
*& Version Author Date description
*& Jimmy 23 Jan 2013 the first version
*& the last update time 2013.01.23 19:00
*&---------------------------------------------------------------------*
report zmm_goods_issue_262_261 no standard page heading.
*&---------------------------------------------------------------------*
* database table
*&---------------------------------------------------------------------*
tables : rlgrap,mkpf.
*&---------------------------------------------------------------------*
* internal table & variables
*&---------------------------------------------------------------------*
data:begin of it_record occurs 0,
order type i,
aufnr like mseg-aufnr,
matnr like mseg-matnr,
bwart like mseg-bwart,
werks like mseg-werks,
lgort like mseg-lgort ,
menge like mseg-menge,
meins like mseg-meins,
charg like mseg-charg,
message type c length 255,
end of it_record.
data:itab like it_record occurs 0 with header line.
data:begin of it_aufnr occurs 0,
bwart like mseg-bwart,
aufnr like mseg-aufnr,
message type c length 255,
end of it_aufnr.
data: it_mseg like mseg occurs 0 with header line.
data: lt_gt_data type alsmex_tabline occurs 0 with header line.
data: msg type string.
data:lv_tabix like sy-tabix,
wa_tabix like sy-tabix.
data:begin of it_mchb occurs 0,
matnr like mara-matnr, "material
werks like marc-werks, "Plant
lgort like mchb-lgort , "location
charg like mchb-charg , "Batch
clabs like mchb-clabs, "
meins like mara-meins,
end of it_mchb.
type-pools: slis.
data: fc_hier type slis_t_fieldcat_alv,
wa_hier type slis_fieldcat_alv .
*----------------------------------------------------------------------*
* Parameter & Select-Options *
*----------------------------------------------------------------------*
selection-screen begin of block 1 with frame title text-001.
parameters:p_bldat like mkpf-bldat default sy-datum obligatory,
p_budat like mkpf-budat default sy-datum obligatory.
parameters filename type rlgrap-filename obligatory.
parameters: p_test as checkbox default 'X'.
selection-screen end of block 1.
*----------------------------------------------------------------------*
* Initialize *
*----------------------------------------------------------------------*
initialization.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN
*----------------------------------------------------------------------*
at selection-screen on value-request for filename.
call function 'WS_FILENAME_GET'
exporting
def_path = 'C:\'
mask = ',Excel Files,*.xls,All Files,*.*.'(101)
mode = 'O'
title = 'Select file'(100)
importing
filename = filename
exceptions
selection_cancel = 1
selection_error = 2
others = 3.
if sy-subrc ne 0.
" .
endif.
*&---------------------------------------------------------------------*
* start of process
*&---------------------------------------------------------------------*
start-of-selection.
refresh: it_record ,lt_gt_data.
clear:it_record,lt_gt_data.
perform manual_upld.
if sy-subrc ne 0.
clear msg.
concatenate 'Upload Filename ' filename ' is Error' into msg.
message msg type 'I'.
exit.
endif.
sort lt_gt_data by row col value.
read table lt_gt_data index 1.
if sy-subrc ne 0.
clear : msg.
concatenate 'Upload File ' filename ' Is Null!' into msg.
message msg type 'I'.
exit.
endif.
perform get_it_record.
if it_record[] is initial.
message 'No Record Found' type 'I'.
exit.
endif.
if p_test is initial.
perform process_data.
else.
itab[] = it_record[].
endif.
perform display_data.
*&---------------------------------------------------------------------*
*& Form MANUAL_UPLD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form manual_upld .
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
text = 'Getting Data........'.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = filename
i_begin_col = '1'
i_begin_row = '2'
i_end_col = '7'
i_end_row = '50000'
tables
intern = lt_gt_data
exceptions
upload_ole = 1.
if sy-subrc ne 0.
" message i004(zmm)
endif.
endform. " MANUAL_UPLD
*&---------------------------------------------------------------------*
*& Form GET_IT_RECORD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form get_it_record .
data:lv_order type i,
lv_date(10) type c. "Pur.Order .
check not lt_gt_data[] is initial.
lv_order = 1.
loop at lt_gt_data.
shift lt_gt_data-value right deleting trailing space.
shift lt_gt_data-value left deleting leading space.
case lt_gt_data-col.
when '1'.
it_record-aufnr = lt_gt_data-value .
perform add_pre_zero using it_record-aufnr
changing it_record-aufnr .
when '2'.
it_record-matnr = lt_gt_data-value.
perform tranfer_material using it_record-matnr
changing it_record-matnr.
when '3'.
it_record-werks = lt_gt_data-value .
when '4'.
it_record-lgort = lt_gt_data-value .
when '5'.
it_record-menge = lt_gt_data-value .
when '6'.
it_record-meins = lt_gt_data-value .
when '7'.
it_record-bwart = lt_gt_data-value .
endcase.
at end of row.
it_record-order = lv_order.
append it_record.
it_aufnr-aufnr = it_record-aufnr.
it_aufnr-bwart = it_record-bwart.
collect it_aufnr.
add 1 to lv_order.
clear:it_record,it_aufnr.
endat.
endloop.
free:lt_gt_data.
endform. " GET_IT_RECORD
*&---------------------------------------------------------------------*
*& Form ADD_PRE_ZERO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IT_RECORD_WEEKS_C text
* <--P_IT_RECORD_WEEKS_C text
*----------------------------------------------------------------------*
form add_pre_zero using p_old
changing p_new .
call function 'CONVERSION_EXIT_ALPHA_INPUT'
exporting
input = p_old
importing
output = p_new.
endform. " ADD_PRE_ZERO
*&---------------------------------------------------------------------*
*& Form TRANFER_MATERIAL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_ITAB_MATNR text
* <--P_ITAB_MATNR_C text
*----------------------------------------------------------------------*
form tranfer_material using p_old
changing p_new .
translate p_old to upper case.
call function 'CONVERSION_EXIT_MATN1_INPUT'
exporting
input = p_old
importing
output = p_new
exceptions
length_error = 1
others = 2.
if sy-subrc <> 0.
p_new = p_old.
endif.
endform. "tranfer_material
*&---------------------------------------------------------------------*
*& Form PROCESS_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form process_data .
data:it_gdmvt_head like bapi2017_gm_head_01,
it_afs_item like bapi2017_gm_item_create
occurs 0 with header line,
lv_mdoc like bapi2017_gm_head_ret-mat_doc,
lv_year like bapi2017_gm_head_ret-doc_year,
lv_menge type mseg-menge.
data:it_gdmvt_code like bapi2017_gm_code value '05'.
data:it_return like bapiret2 occurs 0 with header line.
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
text = 'Processing Data........'.
sort it_aufnr by bwart descending aufnr ascending.
sort it_record by bwart descending aufnr ascending.
loop at it_aufnr.
lv_tabix = sy-tabix.
it_gdmvt_head-pstng_date = p_budat ."posting date
it_gdmvt_head-doc_date = p_bldat . "docmunt date
loop at it_record where bwart = it_aufnr-bwart and aufnr = it_aufnr-aufnr and message = space.
wa_tabix = sy-tabix.
it_afs_item-material = it_record-matnr. " Material Code
it_afs_item-plant = it_record-werks . "Plant
it_afs_item-stge_loc = it_record-lgort. "Storage Location
it_afs_item-move_type = it_record-bwart. "Move type"
it_afs_item-entry_uom = it_record-meins. " Unit
it_afs_item-orderid = it_aufnr-aufnr . "Production order
if it_record-bwart = '261'.
select a~charg a~matnr a~werks a~lgort a~clabs
into corresponding fields of table it_mchb
from mchb as a
where a~matnr = it_record-matnr
and a~werks = it_record-werks
and a~lgort = it_record-lgort
and a~clabs > 0.
if it_mchb[] is not initial.
sort it_mchb by clabs.
lv_menge = it_record-menge.
loop at it_mchb where matnr = it_record-matnr and werks = it_record-werks and lgort = it_record-lgort.
it_record-charg = it_mchb-charg.
it_afs_item-batch = it_record-charg. "batch .
if it_mchb-clabs >= lv_menge.
it_record-menge = lv_menge.
it_afs_item-entry_qnt = it_record-menge . " Quantity
append it_afs_item.
clear:lv_menge .
exit.
else.
it_record-menge = it_mchb-clabs .
it_afs_item-entry_qnt = it_record-menge . " Quantity
append it_afs_item.
lv_menge = lv_menge - it_mchb-clabs.
endif.
endloop.
if lv_menge > 0.
it_record-message = 'No Enough Stock'.
modify it_record index wa_tabix transporting message charg.
endif.
else.
it_record-message = 'No Found Stock'.
modify it_record index wa_tabix transporting message charg.
endif.
clear:it_mchb,it_mchb[],it_record-message,it_record-charg,lv_menge .
else.
it_afs_item-entry_qnt = it_record-menge . " Quantity
append it_afs_item.
endif.
clear : it_afs_item.
endloop.
check it_afs_item[] is not initial.
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header = it_gdmvt_head
goodsmvt_code = it_gdmvt_code
importing
materialdocument = lv_mdoc
matdocumentyear = lv_year
tables
goodsmvt_item = it_afs_item
return = it_return.
read table it_return with key type = 'E'.
if sy-subrc eq 0.
loop at it_return where type = 'E'.
concatenate it_aufnr-message ' E: ' it_return-message into it_aufnr-message.
endloop.
modify it_aufnr index lv_tabix.
else.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
it_aufnr-message = lv_mdoc.
modify it_aufnr index lv_tabix.
endif.
clear: it_afs_item, it_return, it_gdmvt_head,lv_mdoc,lv_year, it_aufnr-message..
refresh: it_afs_item, it_return .
endloop.
sort it_aufnr by bwart aufnr .
loop at it_record.
move-corresponding it_record to itab.
if itab-message = space.
read table it_aufnr with key bwart = itab-bwart aufnr = itab-aufnr binary search.
if sy-subrc eq 0.
itab-message = it_aufnr-message.
endif.
endif.
append itab.
clear itab.
endloop.
free: it_record,it_aufnr,it_afs_item, it_return,it_mchb .
endform. " PROCESS_DATA
*&---------------------------------------------------------------------*
*& Form DISPLAY_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form display_data .
define alv_field.
clear:wa_hier.
wa_hier-fieldname = &1.
wa_hier-seltext_m = &2.
wa_hier-seltext_l = &3.
wa_hier-outputlen = &4.
wa_hier-just = &5.
wa_hier-do_sum = &6.
wa_hier-ref_tabname = &7 .
wa_hier-ref_fieldname = &8 .
append wa_hier to fc_hier.
end-of-definition.
refresh: fc_hier.
alv_field 'AUFNR' '' '' '' 'L' '' 'AFKO' 'AUFNR'.
alv_field 'MATNR' '' 'Material' '18' 'L' '' 'MARA' 'MATNR'.
alv_field 'WERKS' 'Plant' '' '6' 'L' '' '' ''.
alv_field 'LGORT' '' 'Storage Location' '10' 'L' '' '' ''.
alv_field 'MENGE' '' 'Qty' '12' 'R' '' '' ''.
alv_field 'MEINS' 'Unit' '' '6' 'L' '' '' ''.
alv_field 'BWART' '' '' '6' 'L' '' 'MSEG' 'BWART'.
alv_field 'CHARG' 'Batch' '' '10' 'L' '' '' ''.
alv_field 'MESSAGE' 'Message' '' '20' 'L' '' '' ''.
sort itab by order.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = fc_hier[]
i_save = 'A'
i_callback_program = sy-repid
tables
t_outtab = itab[]
exceptions
program_error = 1
others = 2.
endform. " DISPLAY_DATA
Material | Qty |
14-00A087-002-R000 | 1 |
*&---------------------------------------------------------------------*
*& Progarm : zmm_goods_issue_412 Author : Jimmy Wong
*& Created : 18 Mar 2013 App : MM
*& Title : Goods Issue 412
*& Description : Goods Issue 412
*&---------------------------------------------------------------------*
*& Version Author Date description
*& Jimmy 18 Mar 2013 the first version
*& the last update time 2013.03.18 19:00
*&---------------------------------------------------------------------*
report zmm_goods_issue_412.
tables: mkpf,mseg,prps.
data:begin of it_record occurs 0,
matnr like mseg-matnr,
menge like mseg-menge,
end of it_record.
data: lt_gt_data type alsmex_tabline occurs 0 with header line.
data: begin of it_mchb occurs 0,
matnr like mchb-matnr,
werks like mchb-werks,
lgort like mchb-lgort,
charg like mchb-charg,
clabs like mchb-clabs,
end of it_mchb.
data: begin of itab occurs 0,
group type c length 10,
matnr like mchb-matnr,
lgort like mchb-lgort,
charg like mchb-charg,
clabs like mchb-clabs,
clabs_t like mchb-clabs,
message type c length 255,
end of itab.
data: begin of it_gp occurs 0,
group type c length 10,
message type c length 255,
end of it_gp .
data: it_err like itab occurs 0 with header line.
type-pools: slis.
data: fc_hier type slis_t_fieldcat_alv,
wa_hier type slis_fieldcat_alv .
define alv_field.
clear:wa_hier.
wa_hier-fieldname = &1.
wa_hier-seltext_m = &2.
wa_hier-seltext_l = &3.
wa_hier-outputlen = &4.
wa_hier-just = &5.
wa_hier-do_sum = &6.
wa_hier-ref_tabname = &7 .
wa_hier-ref_fieldname = &8 .
append wa_hier to fc_hier.
end-of-definition.
*----------------------------------------------------------------------*
* Parameter & Select-Options *
*----------------------------------------------------------------------*
selection-screen begin of block 1 with frame title text-001.
parameters:p_werks like mseg-werks default '8201' obligatory,
p_bldat like mkpf-bldat default sy-datum obligatory,
p_budat like mkpf-budat default sy-datum obligatory,
p_posid like prps-posid default 'HARMAN' obligatory,
p_sobkz like t148-sobkz default 'Q' obligatory,
p_100 type i default 10 obligatory..
parameters filename type rlgrap-filename obligatory.
parameters: p_test as checkbox default 'X'.
selection-screen end of block 1.
*----------------------------------------------------------------------*
* Initialize *
*----------------------------------------------------------------------*
initialization.
*----------------------------------------------------------------------*
* AT SELECTION-SCREEN
*----------------------------------------------------------------------*
at selection-screen on value-request for filename.
perform get_select_filename_excel using filename.
*&---------------------------------------------------------------------*
* start of process
*&---------------------------------------------------------------------*
start-of-selection.
refresh: it_record ,lt_gt_data.
clear:it_record,lt_gt_data.
perform manual_upld tables lt_gt_data
using filename '1' '2' '2' '50000'.
perform get_it_record.
if it_record[] is initial.
message 'No Record Found' type 'I'.
exit.
endif.
perform get_stock_data.
if it_mchb[] is initial.
message 'No Found Stock' type 'I'.
exit.
endif.
perform process_data.
if p_test is initial.
perform posting_412.
endif.
perform display_data.
end-of-selection.
*&---------------------------------------------------------------------*
*& Form GET_IT_RECORD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form get_it_record .
check not lt_gt_data[] is initial.
loop at lt_gt_data.
shift lt_gt_data-value right deleting trailing space.
shift lt_gt_data-value left deleting leading space.
case lt_gt_data-col.
when '1'.
it_record-matnr = lt_gt_data-value.
perform tranfer_material using it_record-matnr ''
changing it_record-matnr.
when '2'.
it_record-menge = lt_gt_data-value .
endcase.
at end of row.
collect it_record.
clear:it_record.
endat.
endloop.
free:lt_gt_data.
endform. " GET_IT_RECORD
*&---------------------------------------------------------------------*
*& Form GET_STOCK_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form get_stock_data .
sort it_record by matnr.
select matnr werks lgort charg clabs into table it_mchb
from mchb
for all entries in it_record
where matnr = it_record-matnr
and werks = p_werks
and lgort not like 'W%'
and clabs > 0.
endform. " GET_STOCK_DATA
*&---------------------------------------------------------------------*
*& Form PROCESS_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form process_data .
data:lv_menge like mchb-clabs,
lv_i type i,
lv_j type i.
sort it_mchb by matnr ascending charg descending.
lv_i = 1.
lv_j = 1.
loop at it_record.
read table it_mchb with key matnr = it_record-matnr.
if sy-subrc eq 0.
lv_menge = it_record-menge.
* read table it_mchb with key matnr = it_record-matnr clabs = it_record-menge .
* if sy-subrc eq 0.
* itab-matnr = it_record-matnr.
* itab-lgort = it_mchb-lgort.
* itab-charg = it_record-menge.
* itab-clabs = it_mchb-clabs.
* itab-clabs_t = lv_menge.
* itab-group = lv_j .
* condense itab-group.
* concatenate 'A' itab-group into itab-group.
* it_gp-group = itab-group.
* collect it_gp.
* lv_i = lv_i + 1.
* append itab.
* clear: itab.
* if lv_i > p_100.
* lv_i = 1.
* lv_j = lv_j + 1.
* endif.
* else.
loop at it_mchb where matnr = it_record-matnr.
itab-matnr = it_record-matnr.
itab-lgort = it_mchb-lgort.
itab-charg = it_mchb-charg.
itab-clabs = it_record-menge.
itab-group = lv_j .
condense itab-group.
concatenate 'A' itab-group into itab-group.
it_gp-group = itab-group.
collect it_gp.
lv_i = lv_i + 1.
if lv_menge <= it_mchb-clabs.
itab-clabs_t = lv_menge.
append itab.
clear: itab.
if lv_i > p_100.
lv_i = 1.
lv_j = lv_j + 1.
endif.
exit.
else.
itab-group = lv_j .
condense itab-group.
concatenate 'A' itab-group into itab-group.
it_gp-group = itab-group.
collect it_gp.
lv_i = lv_i + 1.
itab-clabs_t = it_mchb-clabs.
append itab.
clear: itab.
if lv_i > p_100.
lv_i = 1.
lv_j = lv_j + 1.
endif.
lv_menge = lv_menge - it_mchb-clabs.
if lv_menge <= 0.
exit.
endif.
endif.
endloop.
* endif.
else.
it_err-matnr = it_record-matnr.
it_err-message = 'No Found Stock Or Material No Exist.'.
append it_err.
clear:it_err.
endif.
endloop.
endform. " PROCESS_DATA
*&---------------------------------------------------------------------*
*& Form tranfer_material
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_OLD text
* -->P_OUTPUT text
* -->P_NEW text
*----------------------------------------------------------------------*
form tranfer_material using p_old
p_output
changing p_new .
if p_output = 'X'.
call function 'CONVERSION_EXIT_MATN1_OUTPUT'
exporting
input = p_old
importing
output = p_new.
else.
data:lv_input type c length 50.
lv_input = p_old.
translate lv_input to upper case.
call function 'CONVERSION_EXIT_MATN1_INPUT'
exporting
input = lv_input
importing
output = p_new
exceptions
length_error = 1
others = 2.
if sy-subrc <> 0.
endif.
endif.
endform. "tranfer_material
*&---------------------------------------------------------------------*
*& Form manual_upld
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->LT_GT_DATA text
* -->P_FILENAME text
* -->P_BEGIN_COL text
* -->P_BEGIN_ROW text
* -->P_END_COL text
* -->P_END_ROW text
*----------------------------------------------------------------------*
form manual_upld tables it_gt_data
using p_filename
p_begin_col
p_begin_row
p_end_col
p_end_row.
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
text = 'Getting Data........'.
data: msg type string.
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = p_filename
i_begin_col = p_begin_col
i_begin_row = p_begin_row
i_end_col = p_end_col
i_end_row = p_end_row
tables
intern = it_gt_data
exceptions
upload_ole = 1.
if sy-subrc ne 0.
clear msg.
concatenate 'Upload Filename ' filename ' is Error' into msg.
message msg type 'I'.
stop.
endif.
endform. "manual_upld
*&---------------------------------------------------------------------*
*& Form get_select_filename
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_FILENAME text
*----------------------------------------------------------------------*
form get_select_filename_excel using p_filename.
call function 'WS_FILENAME_GET'
exporting
def_path = 'C:\'
mask = ',Excel Files,*.xls,All Files,*.*.'(101)
mode = 'O'
title = 'Select file'(100)
importing
filename = p_filename
exceptions
selection_cancel = 1
selection_error = 2
others = 3.
if sy-subrc ne 0.
" .
endif.
endform. "get_select_filename
*&---------------------------------------------------------------------*
*& Form POSTING_412
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form posting_412 .
data:it_gdmvt_head like bapi2017_gm_head_01,
it_afs_item like bapi2017_gm_item_create
occurs 0 with header line,
lv_mdoc like bapi2017_gm_head_ret-mat_doc,
lv_year like bapi2017_gm_head_ret-doc_year,
lv_tabix like sy-tabix.
data:it_gdmvt_code like bapi2017_gm_code value '04'.
data:it_return like bapiret2 occurs 0 with header line.
call function 'SAPGUI_PROGRESS_INDICATOR'
exporting
text = 'Processing Data........'.
sort it_gp by group.
loop at it_gp .
it_gdmvt_head-pstng_date = p_budat ."posting date
it_gdmvt_head-doc_date = p_bldat . "docmunt date
lv_tabix = sy-tabix.
loop at itab where group = it_gp-group.
it_afs_item-material = itab-matnr. " Material Code
it_afs_item-plant = p_werks . "Plant
it_afs_item-stge_loc = itab-lgort. "Storage Location
it_afs_item-move_type = '412'. "Move type"
it_afs_item-batch = itab-charg. "batch .
* it_afs_item-entry_uom = it_record-meins. " Unit
it_afs_item-entry_qnt = itab-clabs_t . " Quantity
it_afs_item-val_wbs_elem = p_posid.
it_afs_item-wbs_elem = p_posid.
it_afs_item-spec_stock = p_sobkz.
append it_afs_item.
clear : it_afs_item.
endloop.
check it_afs_item[] is not initial.
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header = it_gdmvt_head
goodsmvt_code = it_gdmvt_code
importing
materialdocument = lv_mdoc
matdocumentyear = lv_year
tables
goodsmvt_item = it_afs_item
return = it_return.
read table it_return with key type = 'E'.
if sy-subrc eq 0.
loop at it_return where type = 'E'.
concatenate' E: ' it_return-message into it_gp-message.
endloop.
else.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
it_gp-message = lv_mdoc.
endif.
modify it_gp index lv_tabix .
clear: it_afs_item, it_return, it_gdmvt_head,lv_mdoc,lv_year,it_gp-message.
refresh: it_afs_item, it_return .
endloop.
loop at itab.
read table it_gp with key group = itab-group binary search.
if sy-subrc eq 0 .
itab-message = it_gp-message.
modify itab.
endif .
endloop.
loop at it_err.
move-corresponding it_err to itab.
append itab.
endloop.
endform. " POSTING_412
*&---------------------------------------------------------------------*
*& Form DISPLAY_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form display_data .
refresh: fc_hier.
alv_field 'MATNR' '' 'Material' '18' 'L' '' 'MARA' 'MATNR'.
alv_field 'LGORT' '' 'Storage Location' '10' 'L' '' '' ''.
alv_field 'CHARG' '' 'Batch' '10' 'L' '' '' ''.
alv_field 'CLABS' '' 'Qty' '20' 'R' '' '' ''.
alv_field 'CLABS_T' '' 'Transfer Qty' '20' 'R' '' '' ''.
* alv_field 'MEINS' 'Unit' '' '6' 'L' '' '' ''.
alv_field 'MESSAGE' 'Message' '' '50' 'L' '' '' ''.
sort itab by matnr.
perform display_alv tables fc_hier itab using 'A'.
endform. " DISPLAY_DATA
*&---------------------------------------------------------------------*
*& Form display_alv
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->FC_HIER text
* -->ITAB text
* -->P_SAVE text
*----------------------------------------------------------------------*
form display_alv tables fc_hier itab
using p_save .
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = fc_hier[]
i_save = p_save
i_callback_program = sy-repid
tables
t_outtab = itab[]
exceptions
program_error = 1
others = 2.
endform. "display_alv