2013 Jun 12 7:49 PM
I have a requirement to create IDOC for a Mat Doc (MB1A) from Flat file from Application server, Please guide me how to go about.
Please give me steps and dummy program.
Will reward points.
With Regards,
Bala. M
2013 Jun 13 7:15 AM
Hi Bala,
1.You read the data from the flat file present in application server using OPEN DATASET.......CLOSE DATASET.
2.After that split file structure and append it to the internal table.
3. create the MESSAGE TYPE (WE81) IDOC TYPE (WE82) FM(WE57) using the data present in the Internal table.
Thanks & Regards
Pavan.N
I have a requirement to create IDOC for a Mat Doc (MB1A) from Flat file from Application server, Please guide me how to go about.
Please give me steps and dummy program.
Will reward points.
With Regards,
Bala. M
2013 Jun 13 6:27 AM
Hi Bala,
If I understand correctly, you need to create a material document based flat file in application server. Is this the requirement?
If Yes, next level of Questions as follows..
How will be the content in the flat file? Does it have control record and data with relevant segment names?
If Yes, you can do partner profile settings (with message type WMMBXY and process code WMMB in Inbound parameters), File port settings and use tcode WE16 to trigger create IDoc from file and create Material document subsequently.
If No, Create material document without Idoc creating a custom program to read the file and call 'BAPI_GOODSMVT_CREATE' with goodsmvt_code '03' (Check table T158G for goods movement codes).
Regards,
SG.
2013 Jun 13 1:56 PM
Hi,
Thanks for your reply in this regard.
Here is my requirement and flat file details.
How will be the content in the flat file? Does it have control record and data with relevant segment names?
Flat file have Material document header , Posting dates and document dates are sy-datum, Movement type , plant, storage location, Material, QTY , Batch.
There is no Control Record and data record details in it. I need to create / build to have control record and data record using my new Custom program.
Please let me know if you need any more details.
With Regards,
Bala.M
2013 Jun 13 7:15 AM
Hi Bala,
1.You read the data from the flat file present in application server using OPEN DATASET.......CLOSE DATASET.
2.After that split file structure and append it to the internal table.
3. create the MESSAGE TYPE (WE81) IDOC TYPE (WE82) FM(WE57) using the data present in the Internal table.
Thanks & Regards
Pavan.N
2013 Jun 13 1:57 PM
Hi,
Thanks for your reply in this regard.
Here is my requirement and flat file details.
How will be the content in the flat file? Does it have control record and data with relevant segment names?
Flat file have Material document header , Posting dates and document dates are sy-datum, Movement type , plant, storage location, Material, QTY , Batch.
There is no Control Record and data record details in it. I need to create / build to have control record and data record using my new Custom program.
Please let me know if you need any more details.
With Regards,
Bala.M
2013 Jun 13 2:47 PM
Dear Bala,
First Create a Z IDoc Type with the fields available to you in the file
For more details please check the links in the below discussion
http://scn.sap.com/thread/832232
After that in the processing program of your file create an IDoc with this Data in the file with
Static Control Record [Hard Coded with values and send it to you own system].
More details on the same can be found here.
https://scn.sap.com/thread/1458548
I hope this helps.
Regards,
Yakub Shah
2013 Jun 17 3:44 PM
Hi Yakub Shah,
Thanks for your information.
I created a program with your guidelines as follows:
*&---------------------------------------------------------------------*
*& Report ZPM_I_MATDOC*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZPM_I_MATDOC.
TYPES: BEGIN OF t_edidc,
docnum TYPE edidc-docnum,
status TYPE edidc-status,
END OF t_edidc.
DATA : gt_control TYPE TABLE OF edi_dc WITH HEADER LINE,
gt_idocdat TYPE TABLE OF edi_dd WITH HEADER LINE,
wa_edidc TYPE edidc,
i_edidd TYPE STANDARD TABLE OF EDIDD,
wa_edidd TYPE EDIDD.
DATA: gt_edidc TYPE TABLE OF t_edidc,
gs_edidc TYPE t_edidc,
gs_edid4 TYPE edid4.
data: gt_input type STANDARD TABLE OF ZPM_SP_MATDOCU,
gs_input TYPE ZPM_SP_MATDOCU.
DATA: stl_head TYPE E1BP2017_GM_HEAD_01,
stl_gmcode TYPE E1BP2017_GM_CODE,
stl_item TYPE E1BP2017_GM_ITEM_CREATE,
stl_sernr TYPE E1BP2017_GM_SERIALNUMBER.
CONSTANTS: c_evcode TYPE edi_evcode VALUE 'ZMATDOC'.
START-OF-SELECTION.
PERFORM create_idoc TABLES gt_input.
FORM create_idoc TABLES gt_input.
*Local data declaration
data: l_wa_control_records type edidc, "#EC NEEDED
l_i_control_records type standard table of edidc initial size 0,
v_process_data TYPE TEDE2.
clear: wa_edidc,
v_process_data.
**Populate control data
perform sub_pop_control_dat.
*
*Populate data record
perform sub_poulate_data_record.
*
**Populate the master record in sequence as basic type /IRM/AGRMNTS01
* perform sub_populate_i_edidd_seq.
*Create inbound idoc
call function 'IDOC_INBOUND_WRITE_TO_DB'
exporting
pi_do_handle_error = 'X'
pi_return_data_flag = ' '
importing
pe_idoc_number = wa_edidc-docnum
pe_inbound_process_data = v_process_data
tables
t_data_records = i_edidd
changing
pc_control_record = wa_edidc
exceptions
idoc_not_saved = 1
others = 2.
if sy-subrc = 0.
*Commit work
commit work .
l_wa_control_records = wa_edidc.
wa_edidc-docrel = '710'.
wa_edidc-status = '64'.
append wa_edidc to l_i_control_records.
v_process_data-mandt = sy-mandt . "client
v_process_data-evcode = c_evcode. "Process code
v_process_data-edivr2 = '6'.
* v_process_data-evenid = c_evenid. "even id
*Process the inbound idoc
call function 'IDOC_START_INBOUND'
exporting
pi_inbound_process_data = v_process_data
pi_called_online = 'X'
succ_show_flag = 'X'
tables
t_control_records = l_i_control_records
exceptions
invalid_document_number = 1
error_before_call_application = 2
inbound_process_not_possible = 3
old_wf_start_failed = 4
wf_task_error = 5
serious_inbound_error = 6
others = 7.
endif.
ENDFORM. " Create Idoc
*&---------------------------------------------------------------------*
*& Form SUB_POP_CONTROL_DAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SUB_POP_CONTROL_DAT .
* Fill Control Segment
wa_edidc-mandt = sy-mandt.
* wa_edidc-DOCNUM = 1.
wa_edidc-docrel = sy-saprl.
wa_edidc-direct = '2'.
wa_edidc-rcvpor = ' '.
wa_edidc-rcvprt = ' '.
wa_edidc-rcvprn = ' '.
wa_edidc-test = ' '.
wa_edidc-sndpor = 'XXXCLNT001'.
wa_edidc-sndprt = 'LS'.
wa_edidc-SNDPFC = 'LS'.
wa_edidc-sndprn = 'XXXCLNT001'.
wa_edidc-mestyp = 'ZMBGMCR'.
wa_edidc-IDOCTP = 'ZMBGMCR'.
wa_edidc-mesfct = 'MOD'.
ENDFORM. " SUB_POP_CONTROL_DAT
*&---------------------------------------------------------------------*
*& Form SUB_POULATE_DATA_RECORD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM SUB_POULATE_DATA_RECORD .
move 'M00097' to gs_input-matnr. " for testing
move '10' to gs_input-MENGE. " for testing
move 'COST' to gs_input-LGORT. " for testing
move '201' to gs_input-BWART. " for testing
move 'Test ' to gs_input-BKTXT. " for testing
move '1785' to gs_input-CHARG. " for testing
append gs_input to gt_input.
loop at gt_input into gs_input.
* Fill data segments
stl_head-PSTNG_DATE = sy-datum.
stl_head-HEADER_TXT = 'TEST'. "gs_input-BKTXT.
stl_head-DOC_DATE = sy-datum.
wa_edidd-mandt = sy-mandt.
wa_edidd-segnam = 'ZGM_HEAD'.
wa_edidd-sdata = stl_head.
APPEND wa_edidd to i_edidd.
stl_gmcode-gm_code = '03'.
wa_edidd-mandt = sy-mandt.
wa_edidd-segnam = 'ZGM_CODE'.
wa_edidd-sdata = stl_gmcode.
APPEND wa_edidd to i_edidd.
stl_item-MATERIAL = gs_input-MATNR.
stl_item-PLANT = 'MC10'.
stl_item-STGE_LOC = gs_input-LGORT.
stl_item-BATCH = gs_input-CHARG.
stl_item-MOVE_TYPE = gs_input-BWART.
wa_edidd-mandt = sy-mandt.
wa_edidd-segnam = 'ZGM_ITEM'.
wa_edidd-sdata = stl_item.
APPEND wa_edidd to i_edidd.
ENDLOOP.
ENDFORM. " SUB_POULATE_DATA_RECORD
Created ZIDOC TYPE and ZMESSAGE TYPE.
In ZIDOC TYPE :
E1MBGMCR Header Segment
ZGM_HEAD BAPI Communication Structure: Material Document Header Data
ZGM_CODE MMIM: New Key Assignment GM_CODE to Transaction of Inv. Mgmt
ZGM_ITEM BAPI Communication Structure: Create Material Document Item
ZGM_SRNO BAPI Communication Structure: Create Mat. Doc., Serial No.
Created Process Code ZMATDOC & assign Std FM BAPI_IDOC_INPUT1
and in WE20, LS , Added the Message type (Z) and Process code ZMATDOC and Run the program.
Got Error 56
Please suggest where I am doing wrong
With Regards,
Bala.
2013 Jun 17 4:04 PM
Hi,
How you are running your IDOC? Through WE19?
check the Control record fields for your Inbound IDOC
Receiver
Port - check WE21
Partner No. - check WE20
Partner Type - check WE20
Partner Role - can leave blank
Sender
Port - check SM59
Partner No. -
Partner Type -
Partner Role -
Thanks
2013 Jun 17 5:32 PM
Hi,
I ran WE19 and there no entry with my Message type ZMBGMCR in table
TBDBE and TBDBA.
Please advice.
2013 Jun 17 10:53 PM
Hi Bala,
Can you check if you have assinged the FM BAPI_IDOC_INPUT1 has been assinged to the message type and IDOC type in WE57?
Regards,
Rajesh
2013 Jun 18 11:17 AM
Hi Bala,
I think there some connection is missing. Can you go and check WE20 (for partner), WE19 (Port).
Is every thing in place?
2013 Jun 25 2:02 PM
Hi All,
I am able to complete the requirement with the help of you all and here it is:
I developed in two ways and will decide that which one will take it to Production
First Way:
1) Created ZBASIC TYPE and ZMESSAGE TYPE and ZPROCESS CODE.
2) WE20 Setting Partner profiles : with Sender and reciever system is SAP Current Client and Parter type LS
3) WE57 Assigning FM BAPI_IDOC_INPUT1 to Message type
4) Having entry TBDBE ( Here is where I am facing problem to get into transport Request ) as ZBUS2017 and ZFM name and ZMESSAGE TYPE.
5) Custom program and called IDOC_WRITE_AND_START_INBOUND.
Second Way:
1) Used Standard Basic Type MBGMCR03 and Std Msg Type MBGMCR
2) Created Process code Z and assign Std Msg Type MBGMCR.
3) WE20 Setting Partner profiles : with Sender and reciever system is SAP Current Client and Parter type LS
4) WE57 Assigning FM BAPI_IDOC_INPUT1 to Message type MBGMCR.
5) No need to create any entry in TBDBE ( as it already exists with Std BUS2017 )
6) Custom program and called IDOC_WRITE_AND_START_INBOUND.
But the problem with Second way is : I am not getting the Material Document number back to my Custom program.
I am stil researching the same.
With Regards,
Bala M
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |