03-29-2008 1:00 AM
Hi
We are receiving an Inbound IDOC and the data is getting updated into a custom table.
When single record is there its working fine when I receive multiple records then the last record is getting updated ,Please let me know how to update all the records into the custom table.
Below is my code
LOOP AT idoc_contrl.
LOOP AT idoc_data
WHERE docnum = idoc_contrl-docnum.
CASE idoc_data-segnam.
WHEN 'E1MARAM'.
MOVE idoc_data-sdata TO wa_mara.
WHEN 'E1MAKTM'.
MOVE idoc_data-sdata TO wa_makt.
WHEN 'E1MVKEM'.
MOVE idoc_data-sdata TO wa_mvke.
WHEN 'Z1ZMAVL'.
MOVE idoc_data-sdata TO wa_zmavl1.
ENDCASE.
ENDLOOP.
MOVE: wa_mara-matnr TO wa_zmavl-matnr,
wa_mara-pstat TO wa_zmavl-zqspec_rev,
wa_mara-ersda TO wa_zmavl-zdate,
wa_mara-aeszn TO wa_zmavl-ztime,
wa_mara-aenam TO wa_zmavl-zshelf_life,
wa_mara-matkl TO wa_zmavl-matkl,
wa_mvke-pmatn_guid TO wa_zmavl-wgbez,
wa_makt-maktx TO wa_zmavl-maktx,
wa_mara-vpsta TO wa_zmavl-zcust_rev,
wa_mara-mbrsh TO wa_zmavl-zrind,
wa_zmavl1-zmanuf_name TO wa_zmavl-zmanuf_name,
wa_zmavl1-zmanuf_pn TO wa_zmavl-zmanuf_pn,
wa_mara-lvorm TO wa_zmavl-zuse_code,
wa_mara-blatt TO wa_zmavl-zmoist,
wa_mara-bwscl TO wa_zmavl-zccind,
wa_mvke-pmatn_external TO wa_zmavl-zcceff,
wa_mara-mstde TO wa_zmavl-zccdat.
building internal table for the existing FM
APPEND wa_zmavl TO i_zmavl.
ENDLOOP.
03-29-2008 1:35 AM
03-30-2008 8:02 PM
Heres my whole code man....
""Local interface:
*" IMPORTING
*" VALUE(INPUT_METHOD) TYPE BDWFAP_PAR-INPUTMETHD
*" VALUE(MASS_PROCESSING) TYPE BDWFAP_PAR-MASS_PROC
*" EXPORTING
*" VALUE(WORKFLOW_RESULT) TYPE BDWFAP_PAR-RESULT
*" VALUE(APPLICATION_VARIABLE) TYPE BDWFAP_PAR-APPL_VAR
*" VALUE(IN_UPDATE_TASK) TYPE BDWFAP_PAR-UPDATETASK
*" VALUE(CALL_TRANSACTION_DONE) TYPE BDWFAP_PAR-CALLTRANS
*" TABLES
*" IDOC_CONTRL STRUCTURE EDIDC
*" IDOC_DATA STRUCTURE EDIDD
*" IDOC_STATUS STRUCTURE BDIDOCSTAT
*" RETURN_VARIABLES STRUCTURE BDWFRETVAR
*" SERIALIZATION_INFO STRUCTURE BDI_SER
*"----
FUNCTION zm_idoc_input_matmas03.
*- Local data -
DATA: lt_idoc_data LIKE edidd OCCURS 0.
DATA: i_edid4 TYPE TABLE OF edid4,
i_edids TYPE TABLE OF edids,
i_edidc TYPE TABLE OF edidc,
i_docstat TYPE TABLE OF bdidocstat,
wa_docstat TYPE bdidocstat,
wa_edidc TYPE edidc.
internal table declaration for the zmavl table
DATA : i_zmavl TYPE TABLE OF zmavl,
wa_zmavl TYPE zmavl.
work area based on the segment structure
DATA : wa_mara TYPE e1maram,
wa_makt TYPE e1maktm,
wa_zmavl1 TYPE z1zmavl,
wa_mvke TYPE e1mvkem.
internal table declaration for bapi return
DATA : i_bapireturn TYPE TABLE OF bapireturn,
wa_bapireturn TYPE bapireturn.
constant declaration
CONSTANTS: c_aspect_upload TYPE zzwork_id VALUE 'G9999II0001',
c_error TYPE c VALUE 'E',
c_success TYPE c VALUE 'S',
c_msgid TYPE msgid VALUE 'ZM',
c_status_e TYPE edi_status VALUE '51',
c_status_s TYPE edi_status VALUE '53'.
*----
refresh data
perform initialize_data.
LOOP AT idoc_contrl.
LOOP AT idoc_data
WHERE docnum = idoc_contrl-docnum.
CASE idoc_data-segnam.
WHEN 'E1MARAM'.
MOVE idoc_data-sdata TO wa_mara.
WHEN 'E1MAKTM'.
MOVE idoc_data-sdata TO wa_makt.
WHEN 'E1MVKEM'.
MOVE idoc_data-sdata TO wa_mvke.
WHEN 'Z1ZMAVL'.
MOVE idoc_data-sdata TO wa_zmavl1.
ENDCASE.
ENDLOOP.
MOVE: wa_mara-matnr TO wa_zmavl-matnr,
wa_mara-pstat TO wa_zmavl-zqspec_rev,
wa_mara-ersda TO wa_zmavl-zdate,
wa_mara-aeszn TO wa_zmavl-ztime,
wa_mara-aenam TO wa_zmavl-zshelf_life,
wa_mara-matkl TO wa_zmavl-matkl,
wa_mvke-pmatn_guid TO wa_zmavl-wgbez,
wa_makt-maktx TO wa_zmavl-maktx,
wa_mara-vpsta TO wa_zmavl-zcust_rev,
wa_mara-mbrsh TO wa_zmavl-zrind,
wa_zmavl1-zmanuf_name TO wa_zmavl-zmanuf_name,
wa_zmavl1-zmanuf_pn TO wa_zmavl-zmanuf_pn,
wa_mara-lvorm TO wa_zmavl-zuse_code,
wa_mara-blatt TO wa_zmavl-zmoist,
wa_mara-bwscl TO wa_zmavl-zccind,
wa_mvke-pmatn_external TO wa_zmavl-zcceff,
wa_mara-mstde TO wa_zmavl-zccdat.
building internal table for the existing FM
APPEND wa_zmavl TO i_zmavl.
ENDLOOP.
passing the idoc data mapped according to the zmavl table structure to the function module to continue the updation process.
CALL FUNCTION 'ZM_ASPECT_UPLOAD'
EXPORTING
p_workid = c_aspect_upload
TABLES
it_zmavl = i_zmavl
return = i_bapireturn.
update the idoc status
CLEAR idoc_status.
READ TABLE i_bapireturn into wa_bapireturn
WITH KEY type = c_error.
IF sy-subrc <> 0.
idoc_status-docnum = idoc_contrl-docnum.
idoc_status-status = c_status_s.
idoc_status-uname = sy-uname.
idoc_status-repid = sy-repid.
idoc_status-msgty = c_success.
idoc_status-msgid = c_msgid.
idoc_status-msgno = '000'.
idoc_status-msgv1 = wa_zmavl-matnr.
idoc_status-msgv2 = wa_zmavl-zqspec_rev.
return_variables-wf_param = 'PROCESSED_IDOCs'.
return_variables-doc_number = idoc_contrl-docnum.
APPEND return_variables.
ELSE.
idoc_status-docnum = idoc_contrl-docnum.
idoc_status-status = c_status_e.
idoc_status-uname = sy-uname.
idoc_status-repid = sy-repid.
idoc_status-msgty = c_error.
idoc_status-msgid = c_msgid.
idoc_status-msgno = '000'.
idoc_status-msgv1 = wa_zmavl-matnr.
idoc_status-msgv2 = wa_zmavl-zqspec_rev.
idoc_status-msgv3 = wa_bapireturn-message.
return_variables-wf_param = 'ERROR_IDOCS'.
return_variables-doc_number = idoc_contrl-docnum.
APPEND return_variables.
ENDIF.
APPEND idoc_status.
ENDFUNCTION.
03-29-2008 1:53 AM
Hi,
I think at any time we can process only one idoc.
I think the code which you have written is for only one IDOC.
Its better to go to 'SHDB' for recording and give we19 as tcode. fill the necessary details and execute.
Once the recording is completed, then perform BDC . i think the idocs name and other entries can be passed through the flat file.
If you run the bdc program with the data then all the idocs will be posted.
Reward points if helpful.
Thanks and Regards.
03-30-2008 8:16 PM
Hi Banu,
You are not appending the internal table within the loop idoc_data.
LOOP AT idoc_data
WHERE docnum = idoc_contrl-docnum.
CASE idoc_data-segnam.
WHEN 'E1MARAM'.
MOVE idoc_data-sdata TO wa_mara.
WHEN 'E1MAKTM'.
MOVE idoc_data-sdata TO wa_makt.
WHEN 'E1MVKEM'.
MOVE idoc_data-sdata TO wa_mvke.
WHEN 'Z1ZMAVL'.
MOVE idoc_data-sdata TO wa_zmavl1.
ENDCASE.
ENDLOOP.
before this endloop you have to append your internal table like this
CASE idoc_data-segnam.
WHEN 'E1MARAM'.
MOVE idoc_data-sdata TO wa_mara.
move wa_mara-matnt = zwa_mara-matnr.
.
.
.
.
append zwa_mara to i_zmara.
clear zwa_mara.
clear wa_mara.
WHEN 'E1MAKTM'.
MOVE idoc_data-sdata TO wa_makt.
WHEN 'E1MVKEM'.
MOVE idoc_data-sdata TO wa_mvke.
WHEN 'Z1ZMAVL'.
MOVE idoc_data-sdata TO wa_zmavl1.
ENDCASE.
ENDLOOP
Hope it will resolve your problem.
Regards,
Venkat
03-30-2008 9:26 PM
I do agree with that ,but there is problem ...
after the four segments data is appended to the respective internal tables, all these four segments data belongs to one particular material.Even though the Material is same some data in the segments is differreng,finally the data is passed to a internal table i_zmavl and using this Internal table data is updated in to custom table.