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: 

Send an IDOC when the Invoice is blocked.

Former Member
0 Kudos

Dear Friends,

I have a requirement to generate a custom Idoc when a Invoice is blocked . I have clear idea of creating custom idocs and other ALE configurations but confused on How to get the Application data and how to trigger the program when a invoice is blocked. (invoice number , invoice date , and reason for blocking).

Please give a bit of functional input also.As i do not have any Fi/Co consultant for help.

Regrads,

jeevan.

2 REPLIES 2

Former Member
0 Kudos

Dear Friends,

Please come forward to discuss.

Regards,

jeevan.

Former Member
0 Kudos

Hi Check the FM..

IDOC_OUTPUT_INVOIC--and Process code SD09 for Posting the Invoices from sap to external system..

the above function module is used to send invoice through message control..

if you want the custom program to send invoices..follow the below process..

1. Create one custom program and ..and follow the below process..


*&---------------------------------------------------------------------*
*& Report  Z_IDOC_SEND_SHER                                            *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

*IDOC Prg To send Material Data

REPORT  Z_IDOC_SEND_SHER                        .


*Data Declaration
tables : mara,makt.

data : wa_edidc like edidc,
       it_edidc like edidc occurs 0 with header line,
       it_edidd like edidd occurs 0 with header line.

types : begin of t_mat,
          matnr like mara-matnr,
          meins like mara-meins,
          maktx like makt-maktx,
        end of t_mat.


data : it_mat  type standard table of t_mat with header line.



*Selection Screen
parameter : p_matnr like mara-matnr obligatory.

*
**Processing.
*clear zgro.

select A~matnr A~meins B~maktx

into table it_mat

from mara as a inner join makt as b

on a~matnr = b~matnr

where a~matnr = p_matnr.

if sy-subrc <> 0.
  write : 'No Data To Transport & The Process Ends Here'.
else.
  perform f_formulate_control_data.
  perform f_formulate_idoc_data.
  perform f_master_idoc_db.
endif.

*&--------------------------------------------------------------------*
*&      Form  f_formulate_data
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
form f_formulate_control_data.

  wa_edidc-rcvprt = 'LS'.
  wa_edidc-rcvprn = 'ID3CLNT200'.
  wa_edidc-mestyp = 'ZMARA_SHER'.
  wa_edidc-idoctp = 'Z_MAT'.

endform.                    "f_formulate_data

*&--------------------------------------------------------------------*
*&      Form  f_formulate_idoc_data
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
form f_formulate_idoc_data.

  it_edidd-segnam = 'ZMARA_MATNR'.

  read table it_mat with key MATNR = p_MATNR.
  move it_mat to it_edidd-sdata.

  append it_edidd.
  clear it_edidd.

endform.                    "f_formulate_idoc_data

*&--------------------------------------------------------------------*
*&      Form  f_master_idoc_db
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
form f_master_idoc_db.

  call function 'MASTER_IDOC_DISTRIBUTE'
    exporting
      master_idoc_control            = wa_edidc
    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.

  commit work.

  message id 'B1' type 'I' number '038' with '1'.

  message id 'B1' type 'I' number '039' with '1'.


endform.                    "f_master_idoc_db

Regards,

Prabhudas