Difference between revisions of "SAP ABAP IDOC"
From SapWiki
Line 30: | Line 30: | ||
y modificar con la nueva estructura y nueva función ZZALE_CC1_DNLOAD_MINIMASTER | y modificar con la nueva estructura y nueva función ZZALE_CC1_DNLOAD_MINIMASTER | ||
+ | |||
+ | ==MASTER_IDOC_DISTRIBUTE== | ||
+ | <nowiki>FORM genera_idoc. | ||
+ | DATA: idoc_control TYPE edidc, | ||
+ | idoc_data TYPE TABLE OF edidd, | ||
+ | e_idoc_data TYPE edidd, | ||
+ | idoc_tcontrol TYPE TABLE OF edidc, | ||
+ | e_idoc_control TYPE edidc, | ||
+ | state_of_processing_ing TYPE sysubrc, | ||
+ | inbound_process_data_in TYPE tede2, | ||
+ | idoc_num TYPE edi_docnum. | ||
+ | |||
+ | idoc_control-direct = '1'. | ||
+ | idoc_control-status = '03'. | ||
+ | idoc_control-outmod = '2'. | ||
+ | idoc_control-idoctp = 'ZTIHRIPA'. | ||
+ | idoc_control-mestyp = 'Z1HRIPA'. | ||
+ | |||
+ | *** Destinatario | ||
+ | idoc_control-RCVPOR = p_rcvpor. "Puerta Destinatario | ||
+ | idoc_control-RCVPRT = p_rcvprt. "Tipo Mensaje | ||
+ | idoc_control-RCVPRN = p_rcvprn. "Nro. Interlocutor | ||
+ | |||
+ | ***Remitente. | ||
+ | idoc_control-SNDPOR = p_sndpor. "Puerta Remitente | ||
+ | idoc_control-SNDPRT = p_sndprt. "Tipo Mensaje | ||
+ | idoc_control-SNDPRN = p_sndprn. "Nro. Interlocutor | ||
+ | |||
+ | LOOP AT ti_salida. | ||
+ | e_idoc_data-SEGNUM = '0000'. "1. | ||
+ | e_idoc_data-PSGNUM = '000000'. | ||
+ | e_idoc_data-SEGNAM = 'Z1HRIPA'. | ||
+ | e_idoc_data-SDATA = ti_salida. | ||
+ | APPEND e_idoc_data to idoc_data . | ||
+ | CLEAR e_idoc_data. | ||
+ | ENDLOOP. | ||
+ | |||
+ | IF idoc_data[] IS NOT INITIAL. | ||
+ | e_idoc_control = idoc_control. | ||
+ | APPEND e_idoc_control TO idoc_tcontrol. | ||
+ | |||
+ | CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE' | ||
+ | EXPORTING | ||
+ | MASTER_IDOC_CONTROL = idoc_control | ||
+ | TABLES | ||
+ | COMMUNICATION_IDOC_CONTROL = idoc_tcontrol | ||
+ | MASTER_IDOC_DATA = idoc_data | ||
+ | EXCEPTIONS ERROR_IN_IDOC_CONTROL = 1 | ||
+ | ERROR_WRITING_IDOC_STATUS = 2 | ||
+ | ERROR_IN_IDOC_DATA = 3 | ||
+ | SENDING_LOGICAL_SYSTEM_UNKNOWN = 4. | ||
+ | |||
+ | IF sy-subrc EQ 0. | ||
+ | COMMIT WORK. | ||
+ | WAIT UP TO 1 SECONDS. | ||
+ | |||
+ | READ TABLE idoc_tcontrol INTO e_idoc_control | ||
+ | WITH KEY status = '30'. | ||
+ | WRITE: /01 'Se Creo IDOC Nro. : ', e_idoc_control-docnum. | ||
+ | ENDIF. | ||
+ | ENDIF. | ||
+ | ENDFORM.</nowiki> |
Revision as of 17:56, 6 April 2020
Extend the BAPI or complex data type for the IDoc.
(ver nota 1579037 - "ACTION IS NOT POSSIBLE FOR GENERATED IDOCTYPES" when Extending IDOCs)
En este ejemplo extenderemos el tipo de mensaje HRCC1DNPERSO (HR-PDC: Download mini maestro de personal)
1) Trn. Se11
- copiar estructura BAPICC1DNPERSO a ZBAPICC1DNPERSO
- agregar nuevos campos: COMMUNICATION_ID_LONG type COM_ID_LONG
2) Trn. Se37
- copiar BAPI_CC1_DNLOAD_MINIMASTER a ZBAPI_CC1_DNLOAD_MINIMASTER (crear Grp. Funciones ZHR_MINIMASTER), parám. MINI_MASTER con tipo ZBAPICC1DNPERSO.
3) Trn. SWO1
- Crear tipo interface ZRCVPMINIM basado en RCVPMINIMD
- Crear método ZbapiCc1DnloadMinimaster basado en función ZBAPI_CC1_DNLOAD_MINIMASTER (ABAP-->Funciones API)
- Generar.
4) Trn. BDBG
- Crear interface:
Tipo objeto/Tp.interfase: ZRCVPMINIM Método: ZBAPICC1DNLOADMINIMASTER Tipo de mensaje: ZHRCC1DNPERSO Tipo IDOC: ZHRCC1DNPERSO01 Paquete: ZHCM Módulo funciones: ZZALE_CC1_DNLOAD_MINIMASTER Grupo funciones: ZHR_MINIMASTER
5) Copiar programas
RPTCC101 --> ZRPTCC101_V2
y modificar con la nueva estructura y nueva función ZZALE_CC1_DNLOAD_MINIMASTER
MASTER_IDOC_DISTRIBUTE
FORM genera_idoc. DATA: idoc_control TYPE edidc, idoc_data TYPE TABLE OF edidd, e_idoc_data TYPE edidd, idoc_tcontrol TYPE TABLE OF edidc, e_idoc_control TYPE edidc, state_of_processing_ing TYPE sysubrc, inbound_process_data_in TYPE tede2, idoc_num TYPE edi_docnum. idoc_control-direct = '1'. idoc_control-status = '03'. idoc_control-outmod = '2'. idoc_control-idoctp = 'ZTIHRIPA'. idoc_control-mestyp = 'Z1HRIPA'. *** Destinatario idoc_control-RCVPOR = p_rcvpor. "Puerta Destinatario idoc_control-RCVPRT = p_rcvprt. "Tipo Mensaje idoc_control-RCVPRN = p_rcvprn. "Nro. Interlocutor ***Remitente. idoc_control-SNDPOR = p_sndpor. "Puerta Remitente idoc_control-SNDPRT = p_sndprt. "Tipo Mensaje idoc_control-SNDPRN = p_sndprn. "Nro. Interlocutor LOOP AT ti_salida. e_idoc_data-SEGNUM = '0000'. "1. e_idoc_data-PSGNUM = '000000'. e_idoc_data-SEGNAM = 'Z1HRIPA'. e_idoc_data-SDATA = ti_salida. APPEND e_idoc_data to idoc_data . CLEAR e_idoc_data. ENDLOOP. IF idoc_data[] IS NOT INITIAL. e_idoc_control = idoc_control. APPEND e_idoc_control TO idoc_tcontrol. CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE' EXPORTING MASTER_IDOC_CONTROL = idoc_control TABLES COMMUNICATION_IDOC_CONTROL = idoc_tcontrol MASTER_IDOC_DATA = idoc_data EXCEPTIONS ERROR_IN_IDOC_CONTROL = 1 ERROR_WRITING_IDOC_STATUS = 2 ERROR_IN_IDOC_DATA = 3 SENDING_LOGICAL_SYSTEM_UNKNOWN = 4. IF sy-subrc EQ 0. COMMIT WORK. WAIT UP TO 1 SECONDS. READ TABLE idoc_tcontrol INTO e_idoc_control WITH KEY status = '30'. WRITE: /01 'Se Creo IDOC Nro. : ', e_idoc_control-docnum. ENDIF. ENDIF. ENDFORM.