Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

IDOC Status-26

Hi All,

Please look at the below code and let me know where I was doing mistake...

FUNCTION zrfc_park_document.

*"----


""Local interface:

*" IMPORTING

*" VALUE(COMPANY_CODE) TYPE BUKRS OPTIONAL

*" VALUE(FISCAL_YEAR) TYPE GJAHR OPTIONAL

*" VALUE(DOCUMENT_DATE) TYPE BLDAT OPTIONAL

*"----


TABLES: e1fikpf,

e1fiseg.

DATA: i_bkpf LIKE bkpf OCCURS 0 WITH HEADER LINE,

i_bseg LIKE bseg OCCURS 0 WITH HEADER LINE,

wa_bseg like i_bseg,

i_boole LIKE boole.

DATA: BEGIN OF t_idoc_header.

INCLUDE STRUCTURE edidc.

DATA: END OF t_idoc_header.

DATA: BEGIN OF t_idoc_data OCCURS 0.

INCLUDE STRUCTURE edidd.

DATA: END OF t_idoc_data.

DATA: BEGIN OF t_comm_idoc_control OCCURS 0.

INCLUDE STRUCTURE edidc.

DATA: END OF t_comm_idoc_control.

CLEAR t_idoc_data.

REFRESH t_idoc_data.

CLEAR t_idoc_header.

SELECT * FROM bkpf INTO TABLE i_bkpf

WHERE bukrs = company_code

AND gjahr = fiscal_year

AND bldat = document_date

AND bstat = 'V'.

CHECK i_bkpf[] IS NOT INITIAL.

SELECT * FROM bseg INTO TABLE i_bseg

FOR ALL ENTRIES IN i_bkpf

WHERE belnr = i_bkpf-belnr

AND bukrs = company_code

AND gjahr = fiscal_year.

  • CHECK i_bseg[] IS NOT INITIAL.

LOOP AT i_bkpf.

t_idoc_data-segnam = 'E1FIKPF'.

MOVE-CORRESPONDING i_bkpf TO e1fikpf.

t_idoc_data-sdata = e1fikpf.

APPEND t_idoc_data.

READ TABLE i_bseg INTO wa_bseg WITH KEY belnr = i_bkpf-belnr.

IF sy-subrc EQ 0.

t_idoc_data-segnam = 'E1FISEG'.

MOVE-CORRESPONDING wa_bseg TO e1fiseg.

t_idoc_data-sdata = e1fiseg.

APPEND t_idoc_data.

ENDIF.

ENDLOOP.

t_idoc_header-rcvpor = 'SAPXITRFC'.

t_idoc_header-rcvprt = 'LS'.

t_idoc_header-rcvprn = 'XIDCLNT300'.

t_idoc_header-mestyp = 'FIDCC1'.

t_idoc_header-idoctp = 'FIDCCP02'.

CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'

EXPORTING

master_idoc_control = t_idoc_header

TABLES

communication_idoc_control = t_comm_idoc_control

master_idoc_data = t_idoc_data

EXCEPTIONS

error_in_idoc_control = 1

error_writing_idoc_status = 2

error_in_idoc_data = 3

sending_logical_system_unknown = 4

OTHERS = 5.

  • CALL FUNCTION 'FI_IDOC_PREPARE'

  • IMPORTING

  • e_distribute = i_boole

  • TABLES

  • t_bkpf = i_bkpf

  • t_bseg = i_bseg.

IF sy-subrc = 0.

WRITE:/ 'IDoc created.'.

ELSE.

WRITE:/ 'Error',sy-subrc,'in MASTER_IDOC_DISTRIBUTE'.

ENDIF.

COMMIT WORK.

ENDFUNCTION.

Please guide me...

Thanks,

Sony

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question