Application Development and Automation 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: 
Read only

idoc and workflow

Former Member
0 Likes
956

hi friends,

can any one explain how workflow is integrated with idoc>?

Thanks

hi friends,

can any one explain how workflow is integrated with idoc>?

Thanks

6 REPLIES 6
Read only

Former Member
0 Likes
910

hi,

workflow is specifically used for error handling process in conjunction with IDocs

thanks,

krishna

Read only

Former Member
0 Likes
910

Workflow depicts the business activity. In workflow you define tasks and decide the order in which these tasks should be excuted.

For eg. If you receive a purchase order then you need to create a sales order for same. In this case you can create a workflow which would trigger on creation of purchase order.

IDOC are generally used for communication between two systems. IDOC is a collection of segments which holds the data to be transferred from one system to another. In the above example you may receive a purchase order data in form of IDOC. Every idoc has a process code associated with it. Based on the process code a FM or BAPI is assigned which is excuted on reception of an IDOC.

Read only

0 Likes
910

where you will assign your process code?

can anyone send me some document creating a idoc along wit some workflow stuff.

thanks

Read only

0 Likes
910

where you will assign your process code?

can anyone send me some document creating a idoc along wit some workflow stuff.

thanks

Read only

Former Member
0 Likes
910

Hi Ganesh,

Its worth to check the below link. your question is answered already in the below thread.

Regards,

Suresh

Read only

former_member404244
Active Contributor
0 Likes
910

Hi,

plz have a look at the below code..

  • Work areas for the idoc tables.

DATA: wa_data TYPE edidd.

status = '53'. "initial

  • Read the control data information of idoc.

READ TABLE idoc_contrl INTO gwa_control WITH KEY mestyp = 'ZORDRPLY'.

IF sy-subrc EQ 0.

  • Extract the data from the segments.

LOOP AT idoc_data INTO wa_data "LOOP AT idoc_data

WHERE docnum = idoc_contrl-docnum.

CASE wa_data-segnam. " CASE gwa_data-segnam

WHEN 'Z1SCSK'. "Header data

MOVE wa_data-sdata TO gwa_z1scsk.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = gwa_z1scsk

IMPORTING

output = gv_vbeln.

WHEN 'Z1SCSP'. "Item data

MOVE wa_data-sdata TO gwa_z1scsp.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = gwa_z1scsp-posnr

IMPORTING

output = gv_posnr.

gwa_z1scsp-posnr = gv_posnr.

APPEND gwa_z1scsp TO i_z1scsp.

ENDCASE. " CASE gwa_data-segnam

ENDLOOP. "LOOP AT idoc_data

  • Update the sales order

PERFORM order_change.

ELSE.

  • Begin of Mod-001

status = '51'.

bapi_retn_info-type = 'E'.

bapi_retn_info-id = 'ZSDM'.

bapi_retn_info-number = '028'.

bapi_retn_info-message_v1 = 'Wrong'.

bapi_retn_info-message_v2 = 'Message'.

bapi_retn_info-message_v3 = 'Type'.

  • RAISE wrong_function_called.

ENDIF. " IF sy-subrc EQ 0

***********************************************************************

*Start wf

*----


PERFORM wf_start

USING

idoc_contrl-docnum

gv_vbeln

CHANGING

bapi_retn_info.

*----


*end of starting of wf

***********************************************************************

*set status

*----


IF status = '53'.

bapi_retn_info-type = 'S'.

bapi_retn_info-id = 'ZSDM'.

bapi_retn_info-number = '028'.

bapi_retn_info-message_v1 = gv_vbeln.

bapi_retn_info-message_v2 = 'Changed.'.

bapi_retn_info-message_v3 = 'Succcessfully'.

ENDIF.

PERFORM idoc_status_ord_change

TABLES idoc_data

idoc_status

return_variables

USING idoc_contrl

bapi_retn_info

status

workflow_result.

  • End of Mod-001

ENDFUNCTION.

************************************************************************

*Fill in idoc status -- C_MET 28-05-2++6

************************************************************************

FORM idoc_status_ord_change

TABLES idoc_data STRUCTURE edidd

idoc_status STRUCTURE bdidocstat

r_variables STRUCTURE bdwfretvar

USING idoc_contrl LIKE edidc

value(retn_info) LIKE bapiret2

status LIKE bdidocstat-status

wf_result LIKE bdwf_param-result.

CLEAR idoc_status.

idoc_status-docnum = idoc_contrl-docnum.

idoc_status-msgty = retn_info-type.

idoc_status-msgid = retn_info-id.

idoc_status-msgno = retn_info-number.

idoc_status-appl_log = retn_info-log_no.

idoc_status-msgv1 = retn_info-message_v1.

idoc_status-msgv2 = retn_info-message_v2.

idoc_status-msgv3 = retn_info-message_v3.

idoc_status-msgv4 = retn_info-message_v4.

idoc_status-repid = sy-repid.

idoc_status-status = status.

APPEND idoc_status.

IF idoc_status-status = '51'.

wf_result = '99999'.

r_variables-wf_param = 'Error_IDOCs'.

r_variables-doc_number = idoc_contrl-docnum.

READ TABLE r_variables FROM r_variables.

IF sy-subrc <> 0.

APPEND r_variables.

ENDIF.

ELSEIF idoc_status-status = '53'.

CLEAR wf_result.

r_variables-wf_param = 'Processed_IDOCs'.

r_variables-doc_number = idoc_contrl-docnum.

READ TABLE r_variables FROM r_variables.

IF sy-subrc <> 0.

APPEND r_variables.

ENDIF.

ENDIF.

ENDFORM. "idoc_status_ord_change

----


***INCLUDE LZSD_FS007_ORDERCHANGEF01 .

----


&----


*& Form order_change

&----


  • This Form is used for updating the DB tables(vbap,vbep) *

----


FORM order_change .

  • Declaration of internal tables.

DATA : i_vbap TYPE STANDARD TABLE OF vbap,

i_vbep TYPE STANDARD TABLE OF vbep.

  • Declaration of workareas.

DATA : wa_vbap TYPE vbap,

wa_vbep TYPE vbep.

  • Declaration of constants.

CONSTANTS : lc_sno(3) TYPE c VALUE '039',

lc_ino(3) TYPE c VALUE '040',

lc_msg(4) TYPE c VALUE 'ZSD',

lc_emsgty(1) TYPE c VALUE 'E',

lc_smsgty(1) TYPE c VALUE 'S',

lc_estatus(2) TYPE c VALUE '51',

lc_sstatus(2) TYPE c VALUE '53'.

  • Declaration of variable.

DATA : lv_index TYPE syindex,

lv_zzproddt TYPE sydatum.

  • Fetch the data from vbap

SELECT * FROM vbap INTO TABLE i_vbap

WHERE vbeln EQ gv_vbeln.

IF NOT i_vbap IS INITIAL.

  • Fetch the data from vbep

SELECT * FROM vbep INTO TABLE i_vbep

FOR ALL ENTRIES IN i_vbap

WHERE vbeln EQ i_vbap-vbeln

AND posnr EQ i_vbap-posnr.

  • Modify production option date (zzproopdt) of i_vbap

  • and production date(zzproddt) & original production date(zzoprodt)

  • of i_vbep with the data sent by SCS.

lv_index = 1.

LOOP AT i_z1scsp INTO gwa_z1scsp.

LOOP AT i_vbap INTO wa_vbap WHERE posnr = gwa_z1scsp-posnr.

IF sy-subrc EQ 0 .

  • Copies the date value in gwa_z1scsp-zzproopdt to wa_vbap-zzproopdt,

  • if valid date is there in gwa_z1scsp-zzproopdt

PERFORM validate_date USING gwa_z1scsp-zzproopdt

wa_vbap-zzproopdt.

IF NOT wa_vbap-zzproopdt IS INITIAL.

MODIFY i_vbap FROM wa_vbap TRANSPORTING zzproopdt.

ENDIF.

  • Copies the date value in gwa_z1scsp-zzproddt to lv_zzproddt,

  • if valid date is there in gwa_z1scsp-zzproddt

PERFORM validate_date USING gwa_z1scsp-zzproddt

lv_zzproddt.

  • If gwa_z1scsp-zzproddt is not initial then only update in VBEP.

IF NOT lv_zzproddt IS INITIAL.

LOOP AT i_vbep INTO wa_vbep FROM lv_index.

IF wa_vbep-posnr GT wa_vbap-posnr.

lv_index = sy-tabix.

EXIT.

ELSEIF wa_vbep-posnr EQ wa_vbap-posnr.

wa_vbep-zzproddt = lv_zzproddt.

  • Update Original Production date only when its initial.

IF wa_vbep-zzoprodt IS INITIAL.

wa_vbep-zzoprodt = wa_vbep-zzproddt.

ENDIF.

MODIFY i_vbep FROM wa_vbep TRANSPORTING zzproddt zzoprodt.

ENDIF.

CLEAR wa_vbep.

ENDLOOP.

ENDIF.

ELSE.

  • Begin of Mod-001

status = lc_estatus.

bapi_retn_info-type = lc_emsgty.

bapi_retn_info-id = lc_msg.

bapi_retn_info-number = lc_ino.

bapi_retn_info-message_v1 = gwa_z1scsp-posnr.

ENDIF.

ENDLOOP.

IF sy-subrc EQ 4.

status = lc_estatus.

bapi_retn_info-type = lc_emsgty.

bapi_retn_info-id = lc_msg.

bapi_retn_info-number = lc_ino.

bapi_retn_info-message_v1 = gwa_z1scsp-posnr.

ENDIF.

CLEAR: wa_vbap, gwa_z1scsp.

ENDLOOP.

ELSE.

status = lc_estatus.

bapi_retn_info-type = lc_emsgty.

bapi_retn_info-id = lc_msg.

bapi_retn_info-number = lc_sno.

bapi_retn_info-message_v1 = gv_vbeln.

EXIT.

  • End of Mod-001

ENDIF.

  • Update the DB tables

UPDATE vbap FROM TABLE i_vbap.

UPDATE vbep FROM TABLE i_vbep.

ENDFORM. " order_change

&----


*& Form VALIDATE_DATE

&----


  • Converts the date into DATS format and check if it is valid,

  • if valid returns date in p_date_dats else clear it.

----


  • -->p_date_c8 Date in Char format send by SCS

  • -->p_date_dats Date in DATS format.

----


FORM validate_date USING p_date_c8 TYPE char8

p_date_dats TYPE dats.

CLEAR p_date_dats.

p_date_dats = p_date_c8.

CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'

EXPORTING

date = p_date_dats

EXCEPTIONS

plausibility_check_failed = 1

OTHERS = 2.

check sy-subrc NE 0.

CLEAR p_date_dats.

ENDFORM. " VALIDATE_DATE

&----


*& Form wf_start

&----


  • text

----


  • -->P_IDOC_CONTROL_DOCNUM text

  • -->P_GV_VBELN text

  • <--P_BAPI_RETN_INFO text

----


FORM wf_start USING p_idoc_control_docnum

p_gv_vbeln

CHANGING p_bapi_retn_info TYPE bapiret2.

INCLUDE <cntn01>.

DATA: agents LIKE swhactor OCCURS 1 WITH HEADER LINE,

process_type TYPE char1,

idoc_no TYPE edidc-docnum,

creator LIKE swwwihead-wi_creator.

swc_container wi_container.

swc_create_container wi_container.

swc_set_element wi_container 'Document_no' p_gv_vbeln.

swc_set_element wi_container 'Process_type' '1'.

swc_set_element wi_container 'Idoc_no' p_idoc_control_docnum.

CALL FUNCTION 'SWW_WI_START_SIMPLE'

EXPORTING

creator = creator

task = 'WS90200019'

TABLES

agents = agents

wi_container = wi_container

EXCEPTIONS

id_not_created = 1

read_failed = 2

immediate_start_not_possible = 3

execution_failed = 4

invalid_status = 5

OTHERS = 6.

IF sy-subrc <> 0.

p_bapi_retn_info-type = 'E'.

p_bapi_retn_info-id = sy-msgid.

p_bapi_retn_info-number = sy-msgno.

p_bapi_retn_info-message_v1 = sy-msgv1.

p_bapi_retn_info-message_v2 = sy-msgv2.

p_bapi_retn_info-message_v3 = sy-msgv3.

p_bapi_retn_info-message_v4 = sy-msgv4.

ENDIF.

ENDFORM. " wf_start

Regards,

Nagaraj