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

Idoc question

Former Member
0 Likes
364

Hi,

I am asked to write a custom executable program (not a function module) to create outbound idocs with some data from the database tables as for the selection screen data the user entered. Now, how to assign processing code ?

When I go to we41 for this, it is asking for function module, but I am not using any function module here. All I am using is a executable report to create idocs. Please help.

Thank you.

2 REPLIES 2
Read only

Former Member
0 Likes
320

Hi Krishen,

you need to assign processing code only for inbound idocs, incoming into R3.

If, as I understood, you need to send out the idoc then you do not need the processing code, in fact in partner profile you just have to specify the target system (port), the idoc and the message type to be delivered.

Please, have a look at my answer in this thread:

Hope it helps,

Kind Regards,

Sergio

Read only

Former Member
0 Likes
320

Hi,

if you want to use your own idoc,tables and message type

you have to define your own segment(we31),idoc(we30),message type(we81) called for example znw4_test0001 like in the following report. Than define matching between idoc and message type (we82) The segment in my system has only some fields of table sflight.

Than copy following code in your system and execute it

*&---------------------------------------------------------------------*
*& Report  ZNW4_TEST0003
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZNW4_TEST0003  LINE-SIZE 80 LINE-COUNT 65.

TABLES : sflight.

CONSTANTS: c_log_sys LIKE edidc-rcvprn VALUE 'LS_NON_R3',
           c_mesg_type LIKE edidc-mestyp VALUE 'ZNW4_TEST0001',
           c_idoc_typ LIKE edidc-idoctp VALUE 'ZNW4_TEST0001',
           c_daten_segment LIKE edidd-segnam VALUE 'ZNW4_TEST0001'.

DATA : rec_cnt TYPE i,
       gtbl_daten TYPE STANDARD TABLE OF sflight,
       gwa_daten TYPE sflight.

DATA: gwa_daten_segment TYPE sflight.

DATA: control_record_out LIKE edidc,
      int_edidd LIKE edidd OCCURS 0 WITH HEADER LINE,
      it_comm_idocs LIKE edidc OCCURS 0 WITH HEADER LINE.

SELECT-OPTIONS : s_carrid FOR sflight-carrid,
                 s_connid FOR sflight-connid,
                 s_fldate FOR sflight-fldate.

START-OF-SELECTION.
  SELECT *
    FROM sflight
    INTO TABLE gtbl_daten
    WHERE carrid IN s_carrid
    AND   connid IN s_connid
    AND   fldate IN s_fldate.
  DESCRIBE TABLE gtbl_daten LINES rec_cnt.

END-OF-SELECTION.

  IF rec_cnt = 0.
    WRITE: / 'Abbruch, keine Daten gefunden!'.
  ELSE.
    WRITE: / 'Datensätze gelesen:', rec_cnt.
    control_record_out-mestyp = c_mesg_type.
    control_record_out-idoctp = c_idoc_typ.
    LOOP AT gtbl_daten INTO gwa_daten.
      CLEAR gwa_daten_segment.
      MOVE-CORRESPONDING gwa_daten TO gwa_daten_segment.
      int_edidd-segnam = c_daten_segment.
      int_edidd-sdata = gwa_daten_segment.
      APPEND int_edidd.
    ENDLOOP.

    CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
      EXPORTING
        master_idoc_control                  = control_record_out
*     OBJ_TYPE                             = ''
*     CHNUM                                = ''
      TABLES
        communication_idoc_control           = it_comm_idocs
        master_idoc_data                     = int_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.
    ELSE.
      LOOP AT it_comm_idocs.
        WRITE: / 'IDoc generiert. Nr.: ', it_comm_idocs-docnum.
      ENDLOOP.
    ENDIF.

  ENDIF.

This will create an idoc in your system with the status 29 because you haven't the receiver LS_NON_R3.

Hope this helps.

Regards

Bernd