Académique Documents
Professionnel Documents
Culture Documents
Note: Same idoc can exist in different versions e.g. ORDERS01, ORDERS02…..
The difference between versions is that tehre are more segments in newer versions.
REPORT zhr_permitted_act_to_scanners.
TABLES: zhr_aktivititer.
TYPES:
BEGIN OF t_activities,
orgeh LIKE zhr_aktivititer-orgeh,
actid LIKE zhr_aktivititer-actid,
descr LIKE zhr_aktivititer-descr,
posid LIKE prps-posid,
post1 LIKE prps-post1,
END OF t_activities.
DATA:
gt_activities TYPE STANDARD TABLE OF t_activities,
wa_activities TYPE t_activities,
* Number of idoc created
g_num_of_idocs TYPE i,
* IDOC control record
g_idoc_control LIKE edidc,
* Return data from MASTER_IDOC_DISTRIBUTE
gt_comm_idocs TYPE STANDARD TABLE OF edidc,
wa_comm_idocs TYPE edidc,
* IDOC data record
gt_idoc_data TYPE STANDARD TABLE OF edidd,
wa_idoc_data TYPE edidd,
* Structure for idoc segment Z!ACTIV
g_z1activ LIKE z1activ.
*------------------------------------------------------------------------------
* SELECTION SCREEN
*------------------------------------------------------------------------------
* Data selection
SELECT-OPTIONS:
s_orgeh FOR zhr_aktivititer-orgeh.
PARAMETERS:
p_date LIKE sy-datum DEFAULT sy-datum OBLIGATORY.
SELECTION-SCREEN END OF BLOCK SELECTION.
* Communication parameters
SELECTION-SCREEN BEGIN OF BLOCK COMMUNICATION WITH FRAME TITLE text-002.
PARAMETERS:
p_idoctp LIKE edidc-idoctp OBLIGATORY DEFAULT 'ZHRACT01', "Idoc type
p_mestyp LIKE edidc-mestyp OBLIGATORY DEFAULT 'ZHRACT01', "Message type
p_rcvpor LIKE edidc-rcvpor OBLIGATORY DEFAULT 'SAPUXI', "Receiver port
p_rcvprt LIKE edidc-rcvprt OBLIGATORY DEFAULT 'LS', "Receiver partner type
p_rcvprn LIKE edidc-rcvprn OBLIGATORY DEFAULT 'UXICLNT100'. "Receiver partner
SELECTION-SCREEN END OF BLOCK COMMUNICATION.
* Output
SELECTION-SCREEN BEGIN OF BLOCK OUTPUT WITH FRAME TITLE text-010.
PARAMETERS:
p_idoc AS CHECKBOX, "Create idoc
p_report AS CHECKBOX. "Show report
SELECTION-SCREEN END OF BLOCK OUTPUT.
*------------------------------------------------------------------------------
* SELECTION SCREEN OUTPUT
*------------------------------------------------------------------------------
AT SELECTION-SCREEN OUTPUT.
* Protect parameters for idoc type and message type
LOOP AT SCREEN.
IF screen-name = 'P_IDOCTP' OR screen-name = 'P_MESTYP'.
screen-input = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
*------------------------------------------------------------------------------
* START OF SELECTION
*------------------------------------------------------------------------------
START-OF-SELECTION.
PERFORM read_data.
*------------------------------------------------------------------------------
* END OF SELECTION
*------------------------------------------------------------------------------
END-OF-SELECTION.
PERFORM create_control_record.
PERFORM create_data_records.
IF p_idoc = 'X'.
PERFORM distribute_idoc.
ENDIF.
IF p_report = 'X'.
PERFORM show_report.
ENDIF.
*&---------------------------------------------------------------------*
*& Form read_data
*&---------------------------------------------------------------------*
* Read activities from ZHR_AKTIVITITER and the corresponding
* WSB-elements and texts from PRPS
*----------------------------------------------------------------------*
FORM read_data.
REFRESH gt_activities.
SELECT zhr_aktivititer~orgeh
zhr_aktivititer~actid
zhr_aktivititer~descr
prps~posid
prps~post1
INTO CORRESPONDING FIELDS OF TABLE gt_activities
FROM zhr_aktivititer LEFT OUTER JOIN prps
ON prps~pspnr = zhr_aktivititer~pspnr
WHERE zhr_aktivititer~orgeh IN s_orgeh AND
zhr_aktivititer~begda <= p_date AND
zhr_aktivititer~endda >= p_date.
g_idoc_control-mestyp = p_mestyp.
g_idoc_control-idoctp = p_idoctp.
g_idoc_control-rcvpor = p_rcvpor.
g_idoc_control-rcvprt = p_rcvprt.
g_idoc_control-rcvprn = p_rcvprn.
REFRESH gt_idoc_data.
CLEAR:
wa_activities,
l_old_orgeh.
wa_idoc_data-segnam = 'Z1ACTIV'.
g_z1activ-orgeh = wa_activities-orgeh.
g_z1activ-actid = wa_activities-actid.
g_z1activ-descr = wa_activities-descr.
g_z1activ-posid = wa_activities-posid.
g_z1activ-post1 = wa_activities-post1.
REFRESH gt_comm_idocs.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
COMMIT WORK.
ENDIF.
ENDFORM. " distribute_idoc
*&---------------------------------------------------------------------*
*& Form show_report
*&---------------------------------------------------------------------*
* Show report
*----------------------------------------------------------------------*
FORM show_report .
IF p_idoc = 'X'.
* Generated IDOCs
WRITE : / text-003 COLOR COL_HEADING INTENSIFIED ON.
LOOP AT gt_comm_idocs INTO wa_comm_idocs.
WRITE : / wa_comm_idocs-docnum.
ENDLOOP.
SKIP 2.
ENDIF.
CLEAR t_itab_edids40.
t_itab_edids40-docnum = t_docnum.
t_itab_edids40-status = '51'.
t_itab_edids40-repid = sy-repid.
t_itab_edids40-tabnam = 'EDI_DS'.
t_itab_edids40-mandt = sy-mandt.
t_itab_edids40-stamqu = 'SAP'.
t_itab_edids40-stamid = 'B1'.
t_itab_edids40-stamno = '999'.
t_itab_edids40-stapa1 = 'Sold to changed to '.
t_itab_edids40-stapa2 = t_new_kunnr.
t_itab_edids40-logdat = sy-datum.
t_itab_edids40-logtim = sy-uzeit.
APPEND t_itab_edids40.
If not done allready, activate change pointers generally (Transaction BD61) and for the message
type ( Transaction BD50 )
Go to transaction SM59, select R/3 Connections create RFC destination that points to client 200:
Create port
Go to transaction WE21 and create port for client 200. The port should point to the RFC
destination created above
Go to trsansaction WE20 and create partner profile C46CLNT200. Add outbound message type
messsag type MATMAS:
As in the sender system a RFC destination, port and partner profile should be created in the
receiver system cielnt 200. In the partner profile add message type MATMAS:
Set up distribution model
In client C30 set up distribution model to distribute MATMAS idocs to client 200
Go to trsnaction BD64
Press the Add message type button and fill out the dialog box:
The step to distribute material master idocs to other systems using change pointers are:
Program RBDMIDOC which generates idocs from changepointers, can be schedules to run
automatically
Example of distribution model that distributes MATMAS from logical system C46CLNT30L to
XDTCLNT500:
Posting programs have a standard interface for there input, output and table parameters (See
example below).
FUNCTION zidoc_input_zprocord .
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD
*" VALUE(MASS_PROCESSING) LIKE BDWFAP_PAR-MASS_PROC
*" EXPORTING
*" VALUE(WORKFLOW_RESULT) LIKE BDWF_PARAM-RESULT
*" VALUE(APPLICATION_VARIABLE) LIKE BDWF_PARAM-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
*" EXCEPTIONS
*" WRONG_FUNCTION_CALLED
*" OTHERS
*"----------------------------------------------------------------------
DATA:
it_edidd TYPE STANDARD TABLE OF edidd,
wa_z1procord LIKE z1procord,
l_return TYPE string,
* lt_return TYPE STANDARD TABLE OF string,
l_subrc LIKE sy-subrc,
l_posting_error(1) TYPE c,
l_posting_ok(1) TYPE c.
in_update_task = ''.
*----------------------------------------------------------------------
* Loop through all Idocs
*----------------------------------------------------------------------
LOOP AT idoc_contrl.
*----------------------------------------------------------------------
* Select segments belonging to the Idoc
*----------------------------------------------------------------------
REFRESH: it_edidd.
LOOP AT idoc_data WHERE docnum = idoc_contrl-docnum.
APPEND idoc_data TO it_edidd.
ENDLOOP.
*----------------------------------------------------------------------
* Loop through the segments
*----------------------------------------------------------------------
REFRESH idoc_status.
CLEAR:
l_posting_error,
l_posting_ok.
CLEAR l_subrc.
PERFORM call_transaction
USING wa_z1procord
CHANGING l_subrc
l_return.
IF l_subrc = 0.
l_posting_ok = 'X'.
ELSE.
l_posting_error = 'X'.
* APPEND l_return TO lt_return.
ENDIF.
ENDCASE.
ENDLOOP.
*----------------------------------------------------------------------
* Set Idoc status code
*----------------------------------------------------------------------
CLEAR idoc_status.
idoc_status-docnum = idoc_contrl-docnum.
IF l_posting_ok = 'X' AND l_posting_error IS INITIAL.
* Application document posted
idoc_status-status = '53'.
ELSEIF l_posting_error = 'X' AND l_posting_ok IS INITIAL.
* Error: Application document not posted
idoc_status-status = '51'.
idoc_status-msgty = 'E'.
idoc_status-msgid = 'ZPP_SIMATIC_INTERFAC'.
idoc_status-msgno = '11'.
* idoc_status-msgv1 = l_return.
ENDIF.
APPEND idoc_status.
ENDLOOP.
ENDFUNCTION.
How to use a filter in a distribution model
You need to do create a filter for plant in BD64 , You can proceed with following transactions to
do so ..............
Maintain object type for message type (BD59) Client independentThe ALE objects are used to
create links between IDocs and applications objects, to control the serialisation, to filter
messages in the customer model and to use listings. For our own message type and IDoc you
must maintain object types for the links.
If you want to check the serialisation for the message type, then you must maintain object types
for the serialisation. If no serialisation object has been maintained for a given message type, then
the serialisation will not be checked for this message type.To add an object type to our message
type, follow these next few steps:
Enter transaction BD59 (ALE -> Extensions -> ALE object maintenance -> Maintain
object types)3
Type in your message type ZINVRV and press enter
Click on New entries
Enter your object type, LIFNR (We need to use the vendor as a filter object), the segment
name where LIFNR resides, Z1INVRV, a number 1 for the sequence followed by the
actual field name LIFNR
Save and exit
You have now created an object that we’ll use as a filter object in the customer model to
direct the flow of messages to the various logical systems based on the vendors in the filter
of the message type ZINVRV.
We now need to add our new message type to the distribution model.
Configuring the Distribution Model. This task is performed on your ALE reference client.
Perform the Maintain customer distribution model directly function. (ALE -> Distribution
customer model -> Maintain customer distribution model directly)
Specify the customer model you want to maintain and the logical system that is to be the
sender of the messages OR create a new model. (Create model ALE with logical system
ALELS1C400)
Choose the receiving systems to which the sending system must forward message type
ZINVRV to.
For each receiving logical system allocate the message type necessary for communication
to the receiving systems as per ALE configuration procedure.
Create filter objects (in our case LIFNR as the object type with the associated vendor
number, 0000018001 with leading zeros, in the object area) for the message types.
Save the entries.
SEGMENT_READ_COMPLETE Reads the structure and attributes for a since release 4.0B,
segment. In this case, the version of the Hotpackge 42
record types and the release for the
segments must be sent to the function
module.
IDOC_RECORD_READ Reads the structure of the record types since release 4.0B,
for the specified version. Hotpackge 42
RSNAST00 Processes messages that has not bees sendt (processing <>
immediate)
RSNASTED Program, som kaldes fra Output Message Control ved "udskrift" af
ordrer m.v. Indeholder 2 entry points: EDI_PROCESSING og
ALE_PROCESSING. Herfra kaldes det function module, som er
tildelt via partner profilen og process koden.
RBDMIDOC Generates IDOC's from change pointers (You can also use
transaction BD21)
RSEOUT00 Processes outbound IDOC's with status 30, ( IDOC's mass
processing)
RBDAPP01 Processes inbound IDOC's.
RSECHK07 Check if partner profiler is valid
Usefull tables
Table Discription
NAST Message Status
Miscellanous Tips part 2
Getting IDocs linked to Application documents
Displaying and IDoc in a report
Read IDoc from Database
Creating and sending an IDoc
ALE Inbound Pre-Processing
t_object-objkey = itab_data-objky.
t_object-objtype = 'VBRK'.
CALL FUNCTION 'SREL_GET_NEXT_RELATIONS'
EXPORTING
object = t_object
TABLES
roles = t_roles
EXCEPTIONS
internal_error = 1
no_logsys = 2
OTHERS = 3.
*** STEP 3 - Update IDoc status - If you wish to send additional status messages through
REFRESH: itab_edids.
itab_edids-status = c_idoc_status_ok.
itab_edids-msgty = c_info_msg.
itab_edids-msgid = c_msgid.
itab_edids-msgno = c_msgno.
itab_edids-msgv1 = itab_edidc-docnum.
itab_edids-msgv2 = s_edidc-sndprn.
Sometimes it's necessary to change an Idoc before it is processed. One way to achieve this
is to call a function module that updates the IDoc tables before calling the appropriate f
Note that the function module below can be replaced with EDI_DATA_INCOMING if you are usin
method to load IDocs to SAP.
FUNCTION Z_IDOC_INBOUND_ASYNCHRONOUS.
*"----------------------------------------------------------------------
*"*"Local interface:
*" TABLES
*" IDOC_CONTROL_REC_40 STRUCTURE EDI_DC40
*" IDOC_DATA_REC_40 STRUCTURE EDI_DD40
*"----------------------------------------------------------------------
data e1edp16 type e1edp16.
loop at idoc_control_rec_40
where mestyp = 'DELINS'.
loop at IDOC_DATA_REC_40
where docnum = idoc_control_rec_40-docnum and
segnam = 'E1EDP16'.
move IDOC_DATA_REC_40-sdata to e1edp16.
IF not E1EDP16-PRGRS CA 'DWMI'.
delete IDOC_DATA_REC_40.
ENDIF.
endloop.
endloop.
ENDFUNCTION.