cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Generate IDOC from SAP BTP CAP app

arnabdatta3
Active Participant
0 Likes
905

Hi Experts,

For one of the requirements, we need to generate a IDOC in SAP ECC system from SAP BTP CAP application. Can you please give any idea how we can achieve it?

Accepted Solutions (0)

Answers (3)

Answers (3)

MioYasutake
SAP Champion
SAP Champion

@arnabdatta3 

I would recommend using Cloud Integration to generate IDocs. You can send a request from your CAP application to Cloud Integration and delegate the IDoc generation to Cloud Integration.

arnabdatta3
Active Participant
0 Likes
Can you provide any example or blog for this?
arnabdatta3
Active Participant
0 Likes
@ArunJacob This is outbound IDOC example, we want to send the IDOC to S4 system from BTP Cloud system
ArunJacob
Active Participant
0 Likes

Please call this 'MASTER_IDOC_DISTRIBUTE' from BTP:-

DATA: control TYPE edidc,
      data TYPE STANDARD TABLE OF edidd.

control-mestyp = 'ORDERS'.
control-rcvprn = 'RECEIVER'.
control-sndprn = 'SENDER'.

APPEND VALUE #( segnam = 'E1EDK01' sdata = '...' ) TO data.

CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
  EXPORTING
    master_idoc_control = control
  TABLES
    communication_idoc_control = control
    idoc_data_records = data.

Thanks

ArunJacob
Active Participant
0 Likes

Hi,

Assuming Cloud connector is in place , at ECC use function module MASTER_IDOC_DISTRIBUTE

FUNCTION Z_TRIGGER_IDOC.
*"----------------------------------------------------------------------
*"  Importing  VALUE(I_MATNR) TYPE  MATNR
*"----------------------------------------------------------------------

DATA: ls_edidc TYPE edidc,
      lt_edidd TYPE TABLE OF edidd,
      lv_idoc_number TYPE edi_docnum.

CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
  EXPORTING
    master_idoc_control = ls_edidc
  TABLES
    communication_idoc_control = lt_edidd
  EXCEPTIONS
    OTHERS = 1.

ENDFUNCTION.

and in the CAP application:-

import { executeFunction, rfcDestination } from '@sap-cloud-sdk/rfc';

const destination = await rfcDestination({ destinationName: 'ECC_RFC' });

const response = await executeFunction(destination, {
  functionName: 'Z_TRIGGER_IDOC',
  parameters: {
    I_MATNR: '123456'
  }
});

Thanks,

Arun