Application Development 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: 

ALE - IDOC processing

Former Member
0 Kudos

Hello,

we have development a own IDOC for the communicatin with another system.

The InboundProcess is customized via we20 and an inbound function with following paramters


*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(INPUT_METHOD) LIKE  BDWFAP_PAR-INPUTMETHD
*"     VALUE(MASS_PROCESSING) LIKE  BDWFAP_PAR-MASS_PROC
*"  EXPORTING
*"     VALUE(WORKFLOW_RESULT) LIKE  BDWFAP_PAR-RESULT
*"     VALUE(APPLICATION_VARIABLE) LIKE  BDWFAP_PAR-APPL_VAR
*"     VALUE(IN_UPDATE_TASK) LIKE  BDWFAP_PAR-UPDATETASK
*"     VALUE(CALL_TRANSACTION_DONE) LIKE  BDWFAP_PAR-CALLTRANS
*"  TABLES
*"      IDOC_CONTRL STRUCTURE  EDIDC
*"      IDOC_DATA STRUCTURE  EDIDD
*"      IDOC_STATUS STRUCTURE  BDIDOCSTAT
*"      RETURN_VARIABLES STRUCTURE  BDWFRETVAR
*"      SERIALIZATION_INFO STRUCTURE  BDI_SER

In this funtion a event for a workflow is created and change the Status of tge IDOC.


With the function "IDOC_STATUS_WRITE_TO_DATABASE" we want set the status. 
The calling of the function looks so:
  CALL FUNCTION 'IDOC_STATUS_WRITE_TO_DATABASE'
    EXPORTING
      idoc_number               = idoc_contrl-docnum
      IDOC_OPENED_FLAG          = 'X'
*     NO_DEQUEUE_FLAG
    IMPORTING
      idoc_control              = idoc_contrl
    TABLES
      idoc_status               = l_idoc_status_tab
    EXCEPTIONS
      idoc_foreign_lock         = 1
      idoc_not_found            = 2
      idoc_status_records_empty = 3
      idoc_status_invalid       = 4
      db_error                  = 5
      OTHERS                    = 6.

We get the error "No status set by the application to pass ALE".

Can anyone help me!?!

Thanks and greets

Florian Reiter

8 REPLIES 8

Former Member
0 Kudos

the error will be in rfc sm59 or you may not have distrubuted the model bd64 see it

thanking you

Former Member
0 Kudos

Hi Florian,

The message "No status set by the application to pass ALE" is indicating that no messages have been updated into the IDOC_STATUS tab of your custom FM, please add a message into the IDOC Status - Something like "IDOC Posted Successfully" if everything went fine and in case of error "Application Document not posted".

Regards,

Chen

Former Member
0 Kudos

in the Status Tab i set the status on "53",


  l_idoc_status_tab-docnum = idoc_contrl-docnum.
  l_idoc_status_tab-status = '53'.
  APPEND l_idoc_status_tab.

In the Table "EDIDS" are two entries thr first wirth status 53 and the secont with 51.


6070218	04.06.2011	16:20:20	74	04.06.2011	16:20:20	53	DW03							IDOC Posted Successfully
6070218	04.06.2011	16:20:20	75	04.06.2011	16:20:20	51	DW03	SAPLBD20			Kein Statussatz von der Anwendung an ALE übergeben

are the BD64 settings mandatory?

Clemenss
Active Contributor
0 Kudos

Hi Florian,

you try to set the status using FUNCTION 'IDOC_STATUS_WRITE_TO_DATABASE'.

This is wrong.

The status should be returned in your inbound processing function module tables parameter IDOC_STATUS .

One of the last actions in your function (after posting document) is to set the status record based on the last message issued:

form append_idoc_status_bapi
  using    ps_edidc        type edidc
           pt_return       type ty_t_bapiret2
  changing pt_idoc_status  type ty_t_bdidocstat.
  data:
    ls_bdidocstat type bdidocstat.
  field-symbols:
    <return> type bapiret2.
* this Routine must be called only once per IDOC
  move-corresponding ps_edidc to ls_bdidocstat.
* transfer message data
  ls_bdidocstat-msgty    = sy-msgty.
  ls_bdidocstat-msgid    = sy-msgid.
  ls_bdidocstat-msgno    = sy-msgno.
  ls_bdidocstat-msgv1    = sy-msgv1.
  ls_bdidocstat-msgv2    = sy-msgv2.
  ls_bdidocstat-msgv3    = sy-msgv3.
  ls_bdidocstat-msgv4    = sy-msgv4.
  ls_bdidocstat-repid    = sy-repid.
* update IDOC status
  case ls_bdidocstat-msgty.
    when 'S' or 'I'.
      ls_bdidocstat-status = gc_idoc_posted_ok.
    when 'W'.
      ls_bdidocstat-status = gc_idoc_not_fully_posted.
    when 'E' or 'A'.
      ls_bdidocstat-status = gc_idoc_not_posted .
  endcase." ls_bdidocstat-msgty.
* if status = gc_idoc_posted_ok and errors or warnings (from userexit?)
* are present, then set status = gc_idoc_not_fully_posted
  if ls_bdidocstat-status = gc_idoc_posted_ok.
    loop at pt_return assigning <return>
      where type ca 'EAX'.
      ls_bdidocstat-status = gc_idoc_not_fully_posted.
      exit.
    endloop." at pt_return assigning <return>
  endif." ls_bdidocstat-status = gc_idoc_posted_ok.
  append ls_bdidocstat to pt_idoc_status.
endform.                    " append_idoc_status_bapi

using the constants defined in TOP include

CONSTANTS:
  gc_idoc_not_fully_posted   TYPE teds2-status VALUE '52',
  gc_idoc_not_posted         TYPE teds2-status VALUE '51',
  gc_idoc_posted_ok          TYPE teds2-status VALUE '53',

Note: We also passed the RETURN table of the BAPI function we used for posting to make sure a failure of the BAPI is reflected in the status.

If the function uses application log to record all messages, then the reference should be stored in status record, i.e.

loop at pt_idoc_status assigning <idoc_status>.
    <idoc_status>-appl_log = l_lognumber.
  endloop." at pt_idoc_status assigning <idoc_status>.

This allows users direct view of application log from IDOC monitor i.e. BD87.

Regards,

Clemens

Former Member
0 Kudos

Hi Clemens,

i have implemented your coding.

Now the IDOC Processing is correct.

The sy-fields in the following code are empty:


* transfer message data
    ls_bdidocstat-msgty    = sy-msgty.
    ls_bdidocstat-msgid    = sy-msgid.
    ls_bdidocstat-msgno    = sy-msgno.
    ls_bdidocstat-msgv1    = sy-msgv1.
    ls_bdidocstat-msgv2    = sy-msgv2.
    ls_bdidocstat-msgv3    = sy-msgv3.
    ls_bdidocstat-msgv4    = sy-msgv4.
    ls_bdidocstat-repid    = sy-repid.


I have fill the fields hard in the code:
    IF ls_bdidocstat-msgty IS INITIAL.
      ls_bdidocstat-msgty = 'S'.
    ENDIF.

    IF ls_bdidocstat-msgid IS INITIAL.
      ls_bdidocstat-msgid = '00'.
    ENDIF.
    IF ls_bdidocstat-msgno IS INITIAL.
      ls_bdidocstat-msgno = '162'.
    ENDIF.
    IF ls_bdidocstat-msgv1 IS INITIAL.
      ls_bdidocstat-msgv1 = 'Q4 IDOC erfolgreich'.
    ENDIF.

Thanks for your help and greets

Florian

0 Kudos

Hi Florian.

fine.

Let me suggest.

Do not fill the ls_bdidocstat-msgxy fields directly. In our scenario they were always filled because the BAPI we called ended with an error or success message.

You should declare a type string variable and issue a

MESSAGE ... INTO string variable.

You have big advantages: The message INTO will automatically fill all the SY-MSGxy fields, in debugger you can see the full message in the string and you have a where-used-list for the message. For this reason you should create your own message or use a more specific one.

It is always helping maintenance: See the message, do a where-used-check, find the related source code.

Regards,

Clemens

Former Member
0 Kudos

what BAPI do you call in your Inbound IDOC funtion?

Here my complete code of the Inbound function:


FUNCTION z_wfm_order_01_imp.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(INPUT_METHOD) LIKE  BDWFAP_PAR-INPUTMETHD
*"     VALUE(MASS_PROCESSING) LIKE  BDWFAP_PAR-MASS_PROC
*"  EXPORTING
*"     VALUE(WORKFLOW_RESULT) LIKE  BDWFAP_PAR-RESULT
*"     VALUE(APPLICATION_VARIABLE) LIKE  BDWFAP_PAR-APPL_VAR
*"     VALUE(IN_UPDATE_TASK) LIKE  BDWFAP_PAR-UPDATETASK
*"     VALUE(CALL_TRANSACTION_DONE) LIKE  BDWFAP_PAR-CALLTRANS
*"  TABLES
*"      IDOC_CONTRL STRUCTURE  EDIDC
*"      IDOC_DATA STRUCTURE  EDIDD
*"      IDOC_STATUS STRUCTURE  BDIDOCSTAT
*"      RETURN_VARIABLES STRUCTURE  BDWFRETVAR
*"      SERIALIZATION_INFO STRUCTURE  BDI_SER
*"----------------------------------------------------------------------

  DATA: ls_bdidocstat TYPE bdidocstat,
        lt_return     TYPE ty_t_bapiret2.

  FIELD-SYMBOLS: <return> TYPE bapiret2.

  INCLUDE <cntn01>.

  swc_container lt_cont.
  swc_clear_container lt_cont.
  swc_set_element lt_cont 'DOCNUM' idoc_contrl-docnum.
  swc_container_to_persistent lt_cont.

  CALL FUNCTION 'SWE_EVENT_CREATE'
    EXPORTING
      objtype                       =  'ZIE_AUTOZW'
      objkey                        =  space
      event                         =  'IDOC_Q4_IN'
*     CREATOR                       = ' '
*     TAKE_WORKITEM_REQUESTER       = ' '
*     START_WITH_DELAY              = ' '
*     START_RECFB_SYNCHRON          = ' '
*     NO_COMMIT_FOR_QUEUE           = ' '
*     DEBUG_FLAG                    = ' '
*     NO_LOGGING                    = ' '
*     IDENT                         =
*   IMPORTING
*     EVENT_ID                      =
*     RECEIVER_COUNT                =
   TABLES
     event_container               =  lt_cont
   EXCEPTIONS
     objtype_not_found             = 1
     OTHERS                        = 2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE 'X'  NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.

* this Routine must be called only once per IDOC
    MOVE-CORRESPONDING idoc_contrl TO ls_bdidocstat.
* transfer message data
    ls_bdidocstat-msgty    = sy-msgty.
    ls_bdidocstat-msgid    = sy-msgid.
    ls_bdidocstat-msgno    = sy-msgno.
    ls_bdidocstat-msgv1    = sy-msgv1.
    ls_bdidocstat-msgv2    = sy-msgv2.
    ls_bdidocstat-msgv3    = sy-msgv3.
    ls_bdidocstat-msgv4    = sy-msgv4.
    ls_bdidocstat-repid    = sy-repid.

    IF ls_bdidocstat-msgty IS INITIAL.
      ls_bdidocstat-msgty = 'S'.
    ENDIF.

    IF ls_bdidocstat-msgid IS INITIAL.
      ls_bdidocstat-msgid = '00'.
    ENDIF.
    IF ls_bdidocstat-msgno IS INITIAL.
      ls_bdidocstat-msgno = '162'.
    ENDIF.
    IF ls_bdidocstat-msgv1 IS INITIAL.
      ls_bdidocstat-msgv1 = 'Q4 IDOC erfolgreich'.
    ENDIF.

* update IDOC status
    CASE ls_bdidocstat-msgty.
      WHEN 'S' OR 'I'.
        ls_bdidocstat-status = gc_idoc_posted_ok.
      WHEN 'W'.
        ls_bdidocstat-status = gc_idoc_not_fully_posted.
      WHEN 'E' OR 'A'.
        ls_bdidocstat-status = gc_idoc_not_posted .
    ENDCASE." ls_bdidocstat-msgty.
* if status = gc_idoc_posted_ok and errors or warnings (from userexit?)
* are present, then set status = gc_idoc_not_fully_posted
    IF ls_bdidocstat-status = gc_idoc_posted_ok.
      LOOP AT lt_return ASSIGNING <return>
        WHERE type CA 'EAX'.
        ls_bdidocstat-status = gc_idoc_not_fully_posted.
        EXIT.
      ENDLOOP." at pt_return assigning <return>
    ENDIF." ls_bdidocstat-status = gc_idoc_posted_ok.
    APPEND ls_bdidocstat TO idoc_status.
  ENDIF.

ENDFUNCTION.

0 Kudos

Hi Florian,

we created a 100% custom IDOC created from a flat file extracted from a non-sap-legacy system. We used a copy of FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2' because 'BAPI_SALESORDER_CREATEFROMDAT2' does not support certain order types.

Regards,

Clemens