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

custom idoc

Former Member
0 Likes
562

hi all,

sorry for repeating question. my requirement is to create a program, which when executed, creates a custom idoc ( time sheet idoc type ) , using a custom outbound function module. i did all things except coding in function module and calling it in report program.

can any one give some code for out bound function module or atleast any sample code who to call segments , ports, for creating a custom idoc of type time sheet in outbound function module.

its urgent any suggestions are highly appreciated.

thanks in advance,

Suresh.A

hi all,

sorry for repeating question. my requirement is to create a program, which when executed, creates a custom idoc ( time sheet idoc type ) , using a custom outbound function module. i did all things except coding in function module and calling it in report program.

can any one give some code for out bound function module or atleast any sample code who to call segments , ports, for creating a custom idoc of type time sheet in outbound function module.

its urgent any suggestions are highly appreciated.

thanks in advance,

Suresh.A

3 REPLIES 3
Read only

Former Member
0 Likes
528

hi


Creation of an IDoc generation program
The following code extract contains everything needed to generate an IDoc from data contained in a table.
FORM F_110_SEND_IDOC.
CONSTANTS:
*ur message type ZVISTAPM
  C_MESTYP TYPE EDIDC-MESTYP VALUE 'ZVISTAPM',
*ur idoc type ZVISTAPM01
  C_DOCTYP TYPE EDIDC-IDOCTP VALUE 'ZVISTAPM01',
*ur segment name Z1VISTAPM
  C_SEGNAM TYPE EDIDD-SEGNAM VALUE 'Z1VISTAPM'.
DATA:
  I_ZVISTA_PM TYPE ZVISTA_PM_T OCCURS 6000,
  I_EDIDC TYPE EDIDC OCCURS 0,
  I_EDIDD TYPE EDIDD OCCURS 0,
  WA_ZVISTA_PM TYPE ZVISTA_PM_T,
  WA_EDIDC TYPE EDIDC,
  WA_EDIDD TYPE EDIDD,
  WA_Z1VISTAPM TYPE Z1VISTAPM,
  V_OCCMAX TYPE IDOCSYN-OCCMAX,
  V_NBSEG TYPE I.
CLEAR WA_ZVISTA_PM.
CLEAR WA_EDIDC.
* Save the message type and the basic IDoc type
* in the control segment
MOVE C_MESTYP TO WA_EDIDC-MESTYP.
MOVE C_DOCTYP TO WA_EDIDC-IDOCTP.
* Retrieve the maximum number of segments in the basic IDoc
* type
SELECT MIN( OCCMAX )
  FROM IDOCSYN
  INTO V_OCCMAX
  WHERE IDOCTYP EQ C_DOCTYP AND SEGTYP EQ C_SEGNAM.
* Save the whole ZVISTA_PM_T table content
* in the I_ZVISTA_PM internal table.
SELECT *
FROM ZVISTA_PM_T
INTO CORRESPONDING FIELDS OF TABLE I_ZVISTA_PM.
* Create a data segment for each line of I_ZVISTA_PM
LOOP AT I_ZVISTA_PM INTO WA_ZVISTA_PM.
  MOVE-CORRESPONDING WA_ZVISTA_PM TO WA_Z1VISTAPM.
  CLEAR WA_EDIDD.
  MOVE C_SEGNAM TO WA_EDIDD-SEGNAM.
  MOVE WA_Z1VISTAPM TO WA_EDIDD-SDATA.
  APPEND WA_EDIDD TO I_EDIDD.
  CLEAR WA_ZVISTA_PM.
  CLEAR WA_Z1VISTAPM.
ENDLOOP.
* Count the number of data segments
DESCRIBE TABLE I_EDIDD LINES V_NBSEG.
* If the number of data segments exceeds the maximum
* allowed number, then edit a message in the spool,
* then display an error message (quit the program)
IF V_NBSEG GT V_OCCMAX.
  WRITE:/ TEXT-003, V_OCCMAX.
  MESSAGE E751.
ENDIF.
* Call the IDoc creation function
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
  EXPORTING
    MASTER_IDOC_CONTROL = WA_EDIDC
  TABLES
    COMMUNICATION_IDOC_CONTROL = I_EDIDC
    MASTER_IDOC_DATA = I_EDIDD
  EXCEPTIONS
    ERROR_IN_IDOC_CONTROL = 1
    ERROR_WRITING_IDOC_STATUS = 2
    ERROR_IN_IDOC_DATA = 3
    SENDING_LOGICAL_SYSTEM_UNKNOWN = 4
    OTHERS = 5.
* If there was an error, display a message (quit the
* program)
IF SY-SUBRC NE 0.
  MESSAGE E746.
ENDIF.
ENDFORM.

regards
ravish

<b>plz dont forget to reward points if helpful</b>

Message was edited by:

ravish goyal

Read only

Former Member
0 Likes
528

Hi

I hope this code will help you..

It calls the sements and populate the data into it.

execute this program.

CONSTANTS: C_DOCTYP TYPE EDIDC-IDOCTP VALUE 'ZUSRDET01', idoc type

C_SEGNAM TYPE EDIDD-SEGNAM VALUE 'Z1USRDET01', segment type

C_MESTYP TYPE EDIDC-MESTYP VALUE 'ZUSRDET'. message type

DATA: IT_ZUSR02 TYPE USR02 OCCURS 10,

IT_EDIDC TYPE EDIDC OCCURS 0,

IT_EDIDD TYPE EDIDD OCCURS 0,

WA_ZUSR02 TYPE USR02,

WA_EDIDC TYPE EDIDC,

WA_EDIDD TYPE EDIDD,

WA_Z1USRDET01 TYPE Z1USRDET01,

V_OCCMAX TYPE IDOCSYN-OCCMAX,

V_NBSEG TYPE I.

CLEAR WA_ZUSR02.

CLEAR WA_EDIDC.

  • Save the message type and the basic IDoc type in the control segment.

MOVE C_MESTYP TO WA_EDIDC-MESTYP.

MOVE C_DOCTYP TO WA_EDIDC-IDOCTP.

  • Retrieve the maximum number of segments in the basic IDoc type.

SELECT MIN( OCCMAX ) FROM IDOCSYN INTO V_OCCMAX WHERE IDOCTYP EQ C_DOCTYP AND SEGTYP EQ C_SEGNAM.

  • Save the whole USR02 table content in the IT_ZUSR02 internal table.

SELECT * FROM USR02 INTO CORRESPONDING FIELDS OF TABLE IT_ZUSR02.

  • Create a data segment for each line of IT_ZUSR02.

LOOP AT IT_ZUSR02 INTO WA_ZUSR02 .

MOVE-CORRESPONDING WA_ZUSR02 TO WA_Z1USRDET01.

CLEAR WA_EDIDD.

MOVE C_SEGNAM TO WA_EDIDD-SEGNAM.

MOVE WA_Z1USRDET01 TO WA_EDIDD-SDATA.

APPEND WA_EDIDD TO IT_EDIDD.

CLEAR WA_ZUSR02.

CLEAR WA_Z1USRDET01.

ENDLOOP.

  • Count the number of data segments.

DESCRIBE TABLE IT_EDIDD LINES V_NBSEG.

  • If the number of data segments exceeds the maximum allowed number,then display an error message.

IF V_NBSEG GT V_OCCMAX.

WRITE:/ 'ERROR'.

ENDIF.

CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'

EXPORTING

master_idoc_control = WA_EDIDC

  • OBJ_TYPE = ''

  • CHNUM = ''

tables

communication_idoc_control = IT_EDIDC

master_idoc_data = IT_EDIDD

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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

<b>

Please Reward points for useful ans.</b>

Regards

Aarti

Read only

Former Member
0 Likes
528

answered