Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Customized IDoc to XML

Former Member
0 Likes
1,004

Hi,

I have created a customized IDoc by a customized function module MASTER_IDOC_CREATE using the standard function module MASTER_IDOC_DISTRIBUTE to create and send the IDoc to my SAP system at an XML port without a message control because I put the function module call in an existing program that contains data for the IDoc data segments; now I have an ALE service error in the status record because the sender and receiver systems are the same, how I can resolve my problem to map the IDoc into an XML file stored in a local path. please help me

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
866

Hi,

thank you for your answers maybe I didn't explain my problem very well; for this reason I post my MASTER_IDOC_CREATE function:

FUNCTION master_idoc_create_zord.

*"----

-


""Interfaccia locale:

*" IMPORTING

*" VALUE(APPL_HEADER) LIKE ZCARTSEG STRUCTURE ZCARTSEG

*" TABLES

*" APPL_ITEM STRUCTURE ZCARTSEGPOS

*" EXCEPTIONS

*" NOT_CREATE

*"----

-


*variables·of·general·interest

DATA:

*·······control·record·for·the·IDoc

idoc_control LIKE edidc,

*·······data·records·for·the·IDoc

t_idoc_data LIKE edidd OCCURS 0 WITH HEADER LINE,

*·······table·for·the·IDocs·created·by·MASTER_IDOC_CONTROL

t_comm_control LIKE edidc OCCURS 0 WITH HEADER LINE,

*·······partner·type·for·logical·system

c_partner_type_logical_system LIKE edidc-rcvprt VALUE 'LS',

*·······help·variable·for·the·check·if·an·IDoc·has·to·be·created

h_create_idoc,

c_partner_num_logical_system LIKE edidc-rcvprn VALUE 'WIN',

porta type edipox.

*·variables·specific·for·this·example

DATA:

*·······field·strings·with·IDoc·segment·structure

e1xhead LIKE zseg,

e1xitem LIKE zsegpos occurs 10 with header line,

*·······data·to·be·put·to·the·control·record

c_message_type LIKE edidc-mestyp VALUE 'ZORD',

c_base_idoc_type LIKE edidc-idoctp VALUE 'ZIDOCCAR',

*·······segment·types·to·be·put·to·the·data·record·table

c_header_segtyp LIKE edidd-segnam VALUE 'ZSEG',

c_item_segtyp LIKE edidd-segnam VALUE 'ZSEGPOS',

c_porta like edidc-rcvpor value 'zxml'.

clear idoc_control.

MOVE c_base_idoc_type TO idoc_control-doctyp.

MOVE c_message_type TO idoc_control-mestyp.

MOVE c_partner_type_logical_system TO idoc_control-rcvprt.

MOVE c_partner_num_logical_system TO idoc_control-rcvprn.

idoc_control-rcvpfc = 'LS'.

move c_porta to idoc_control-rcvpor.

*·put·the·application·header·record·to·the·IDoc

MOVE-CORRESPONDING appl_header TO e1xhead.

*·append·record·to·IDoc·data·table

t_idoc_data-segnam = c_header_segtyp.

t_idoc_data-sdata = e1xhead.

APPEND t_idoc_data.

clear t_idoc_data.

LOOP AT appl_item.

*···put·the·application·item·record·to·the·IDoc·segment

MOVE appl_item TO e1xitem.

append e1xitem.

*···append·record·to·IDoc·data·table

t_idoc_data-segnam = c_item_segtyp.

t_idoc_data-sdata = e1xitem.

APPEND t_idoc_data.

clear t_idoc_data.

clear e1xitem.

ENDLOOP.

CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'

*·in·update·task···"if·application·document·is·posted·in·update·task

EXPORTING

master_idoc_control = idoc_control

TABLES

communication_idoc_control = t_comm_control

master_idoc_data = t_idoc_data

exceptions

error_in_idoc_control = 1

error_writing_idoc_status = 2

error_in_idoc_data = 3

sending_logical_system_unknown = 4

others = 5.

if sy-subrc <> 0.

message e007(z0) with sy-subrc.

endif.

*·A·commit·work·has·to·be·done.·It·could·also·be·done·in·the·calling

*·application.

COMMIT WORK.

READ TABLE t_comm_control INDEX 1.

IF sy-subrc <> 0.

MESSAGE e004(z0).

RAISE not_create.

ENDIF.

Note that parameters appl_item and appl_header are filled by calling custom ABAP program. What I have to do now to create XML file from IDoc? Please help me.

Hi,

I have created a customized IDoc by a customized function module MASTER_IDOC_CREATE using the standard function module MASTER_IDOC_DISTRIBUTE to create and send the IDoc to my SAP system at an XML port without a message control because I put the function module call in an existing program that contains data for the IDoc data segments; now I have an ALE service error in the status record because the sender and receiver systems are the same, how I can resolve my problem to map the IDoc into an XML file stored in a local path. please help me

4 REPLIES 4
Read only

Former Member
0 Likes
866

Can you explain you error little more brief with example..

Let me know the ALE error to help you..

Ram..

Read only

former_member194669
Active Contributor
0 Likes
866

now I have an ALE service error in the status record because the sender and receiver systems are the same,

Why you are sending to same system? You want to send to receiver destination you need to create receiver port & partner profile associated with that.

Read only

Former Member
0 Likes
867

Hi,

thank you for your answers maybe I didn't explain my problem very well; for this reason I post my MASTER_IDOC_CREATE function:

FUNCTION master_idoc_create_zord.

*"----

-


""Interfaccia locale:

*" IMPORTING

*" VALUE(APPL_HEADER) LIKE ZCARTSEG STRUCTURE ZCARTSEG

*" TABLES

*" APPL_ITEM STRUCTURE ZCARTSEGPOS

*" EXCEPTIONS

*" NOT_CREATE

*"----

-


*variables·of·general·interest

DATA:

*·······control·record·for·the·IDoc

idoc_control LIKE edidc,

*·······data·records·for·the·IDoc

t_idoc_data LIKE edidd OCCURS 0 WITH HEADER LINE,

*·······table·for·the·IDocs·created·by·MASTER_IDOC_CONTROL

t_comm_control LIKE edidc OCCURS 0 WITH HEADER LINE,

*·······partner·type·for·logical·system

c_partner_type_logical_system LIKE edidc-rcvprt VALUE 'LS',

*·······help·variable·for·the·check·if·an·IDoc·has·to·be·created

h_create_idoc,

c_partner_num_logical_system LIKE edidc-rcvprn VALUE 'WIN',

porta type edipox.

*·variables·specific·for·this·example

DATA:

*·······field·strings·with·IDoc·segment·structure

e1xhead LIKE zseg,

e1xitem LIKE zsegpos occurs 10 with header line,

*·······data·to·be·put·to·the·control·record

c_message_type LIKE edidc-mestyp VALUE 'ZORD',

c_base_idoc_type LIKE edidc-idoctp VALUE 'ZIDOCCAR',

*·······segment·types·to·be·put·to·the·data·record·table

c_header_segtyp LIKE edidd-segnam VALUE 'ZSEG',

c_item_segtyp LIKE edidd-segnam VALUE 'ZSEGPOS',

c_porta like edidc-rcvpor value 'zxml'.

clear idoc_control.

MOVE c_base_idoc_type TO idoc_control-doctyp.

MOVE c_message_type TO idoc_control-mestyp.

MOVE c_partner_type_logical_system TO idoc_control-rcvprt.

MOVE c_partner_num_logical_system TO idoc_control-rcvprn.

idoc_control-rcvpfc = 'LS'.

move c_porta to idoc_control-rcvpor.

*·put·the·application·header·record·to·the·IDoc

MOVE-CORRESPONDING appl_header TO e1xhead.

*·append·record·to·IDoc·data·table

t_idoc_data-segnam = c_header_segtyp.

t_idoc_data-sdata = e1xhead.

APPEND t_idoc_data.

clear t_idoc_data.

LOOP AT appl_item.

*···put·the·application·item·record·to·the·IDoc·segment

MOVE appl_item TO e1xitem.

append e1xitem.

*···append·record·to·IDoc·data·table

t_idoc_data-segnam = c_item_segtyp.

t_idoc_data-sdata = e1xitem.

APPEND t_idoc_data.

clear t_idoc_data.

clear e1xitem.

ENDLOOP.

CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'

*·in·update·task···"if·application·document·is·posted·in·update·task

EXPORTING

master_idoc_control = idoc_control

TABLES

communication_idoc_control = t_comm_control

master_idoc_data = t_idoc_data

exceptions

error_in_idoc_control = 1

error_writing_idoc_status = 2

error_in_idoc_data = 3

sending_logical_system_unknown = 4

others = 5.

if sy-subrc <> 0.

message e007(z0) with sy-subrc.

endif.

*·A·commit·work·has·to·be·done.·It·could·also·be·done·in·the·calling

*·application.

COMMIT WORK.

READ TABLE t_comm_control INDEX 1.

IF sy-subrc <> 0.

MESSAGE e004(z0).

RAISE not_create.

ENDIF.

Note that parameters appl_item and appl_header are filled by calling custom ABAP program. What I have to do now to create XML file from IDoc? Please help me.

Read only

0 Likes
866

Hi Emanuele Morretta

In you Program ..Control Record...

You are assigning the Port Parameter values :

1 c_porta like edidc-rcvpor value 'zxml'.

2 move c_porta to idoc_control-rcvpor. and

3 passing in to FM master_idoc_control = idoc_control

port: ZXML Value should be like XML FILE Post in WE21 Transaction...... not file port or other

U can see the XML File in the file Directory Mentioned in port: ZXML

I hope got the answer for your question....

Ramesh