Skip to Content
author's profile photo
Former Member

idoc function module

hi to all

can u pls tell is thre any function module to populate the data in to userdefined idoc .

points will be rewarded for good answers .

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 10:24 AM

    Hi,

    chek the sample program

    &----


    *& Report ZZ_Program_To_Create_Idoc

    &----


    report zz_program_to_create_idoc .

    tables: ekko,ekpo.

    selection-screen skip 3.

    selection-screen begin of block b1 with frame title titl.

    selection-screen skip.

    select-options s_ebeln for ekko-ebeln.

    selection-screen skip.

    selection-screen end of block b1.

    data: header_segment_name like edidd-segnam value 'Z1EKKO',

    item_segment_name like edidd-segnam value 'Z1EKPO',

    idoc_name like edidc-idoctp value 'Z19838IDOC1'.

    data: header_segment_data like z1ekko,

    item_segment_data like z1ekpo.

    data: control_record like edidc.

    data: messagetyp like edmsg-msgtyp value 'ZZ9838MESG1'.

    data: i_communication like edidc occurs 0 with header line,

    i_data like edidd occurs 0 with header line.

    data: begin of i_ekko occurs 0,

    ebeln like ekko-ebeln,

    aedat like ekko-aedat,

    bukrs like ekko-bukrs,

    bsart like ekko-bsart,

    lifnr like ekko-lifnr,

    end of i_ekko.

    data: begin of i_ekpo occurs 0,

    ebelp like ekpo-ebelp,

    matnr like ekpo-matnr,

    menge like ekpo-menge,

    meins like ekpo-meins,

    netpr like ekpo-netpr,

    end of i_ekpo.

    start-of-selection.

    select ebeln aedat bukrs bsart lifnr from ekko

    into table i_ekko where ebeln in s_ebeln.

    select ebelp

    matnr

    menge

    meins

    netpr

    from ekpo

    into table i_ekpo

    where ebeln in s_ebeln.

    control_record-mestyp = messagetyp.

    control_record-rcvprt = 'LS'.

    control_record-idoctp = idoc_name.

    control_record-rcvprn = '0MART800'.

    loop at i_ekko.

    header_segment_data-ebeln = i_ekko-ebeln.

    header_segment_data-aedat = i_ekko-aedat.

    header_segment_data-bukrs = i_ekko-bukrs.

    header_segment_data-bsart = i_ekko-bsart.

    header_segment_data-lifnr = i_ekko-lifnr.

    i_data-segnam = header_segment_name.

    i_data-sdata = header_segment_data.

    append i_data.

    select ebelp

    matnr

    menge

    meins

    netpr

    from ekpo

    into table i_ekpo

    where ebeln = i_ekko-ebeln.

    loop at i_ekpo.

    item_segment_data-ebelp = i_ekpo-ebelp.

    item_segment_data-matnr = i_ekpo-matnr.

    item_segment_data-menge = i_ekpo-menge.

    item_segment_data-meins = i_ekpo-meins.

    item_segment_data-netpr = i_ekpo-netpr.

    i_data-segnam = item_segment_name.

    i_data-sdata = item_segment_data.

    append i_data.

    endloop.

    clear i_ekpo.

    refresh i_ekpo.

    endloop.

    call function 'MASTER_IDOC_DISTRIBUTE'

    exporting

    master_idoc_control = control_record

    • OBJ_TYPE = ''

    • CHNUM = ''

    tables

    communication_idoc_control = i_communication

    master_idoc_data = i_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 id sy-msgid type sy-msgty number sy-msgno

    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    else.

    loop at i_communication.

    write: 'IDOC GENERATED', i_communication-docnum.

    endloop.

    commit work.

    endif.

    initialization.

    titl = 'ENTER THE PURCHASE ORDER NUMBER'.

    Regards,

    Nagaraj

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 10:26 AM

    using MASTER_IDOC_DISTRIBUTE u can populate data into idoc.

    reward if useful.

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 28, 2007 at 10:26 AM

    Hi

    The FM that generates the IDOCs in outbound is MASTER_IDOC_Distribute.

    This is the Sample Outbound program:

    Sample Program For IDOC Outbound Processing

    FORM F_110_SEND_IDOC.

    CONSTANTS:

    C_MESTYP TYPE EDIDC-MESTYP VALUE 'ZVISTAPM',

    C_DOCTYP TYPE EDIDC-IDOCTP VALUE 'ZVISTAPM01',

    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.

    <b>reward if Helpful.</b>

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 10:28 AM

    What data you are passing??? There are standard IDOC FM's depends on the data...

    Add comment
    10|10000 characters needed characters exceeded