SAP document output

You can clone the delivered SAP output programs in order to call the Floe API instead of triggering output using SAPScript, SMARTFORMS or SAP Interactive Forms by Adobe.

For example, in document output controlled by the NAST table and RSNAST00 etc., then the output can continue to be managed and triggered in the same way, and messages sent as normal using function 'NAST_PROTOCOL_UPDATE'.

Here are examples of some print programs.  These may need to be changed based on the version of Business Suite / S/4HANA you are running.

Sales order (ECC): ZSD_SALESDOC_FLOE.txt

Sales order (S4H): ZSD_SALESDOC_FLOE.txt

Delivery (S4H): ZSD_DELIVERYDOC_FLOE.txt

Billing Document (S4H): ZSD_BILLINGDOC_FLOE.txt

Purchase Order (S4H): ZPTP_PURCHASEDOC_VARO.txt  ZPTP_VARO1.txt

----

Here is an explanation of how a sales order output print program could be changed to include Floe integration

In this example, Floe is installed on a separate SAP instance.

Entry point:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
*---------------------------------------------------------------------*
*       FORM ENTRY                                                    *
*---------------------------------------------------------------------*
FORM entry                                                  "#EC CALLED
     USING cv_returncode  TYPE sysubrc
           uv_screen      TYPE char1.

* Assign RC
  ASSIGN cv_returncode TO <gv_returncode>.

* Refresh global data
  PERFORM initialize_data.

* Set data and start processing
  gv_screen_display = uv_screen.
  gs_nast           = nast.
  PERFORM processing.

ENDFORM.                    "entry

Processing block:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
*&---------------------------------------------------------------------*
*&      Form  processing
*&---------------------------------------------------------------------*
FORM processing.

* Retrieve the data
  PERFORM get_data.
  CHECK <gv_returncode> IS INITIAL.

* Print, fax, send data
  PERFORM print_data.
  CHECK <gv_returncode> IS INITIAL.


ENDFORM.                    " processing

After data selection, fill Floe variable table

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
*
* Convert data into floe variables.
*
* Take header data from structure <gs_vbdka>.
  GET REFERENCE OF <gs_vbdka> INTO ldo_data .
  lo_struct ?=  cl_abap_structdescr=>describe_by_data_ref( ldo_data ).
  lt_comp = lo_struct->components.

  LOOP AT lt_comp INTO ls_comp_a.
    ASSIGN COMPONENT ls_comp_a-name OF STRUCTURE <gs_vbdka> TO <lo_field>.
    gs_vars-var_code = ls_comp_a-name.
    gs_vars-value = <lo_field>.
    APPEND gs_vars TO gt_vars.
  ENDLOOP.

  DATA: ls_item_detail TYPE vbdpa.

* Take item data and schedule line data from table vbdpa.
  GET REFERENCE OF lt_vbdpa INTO ldo_data .
  ASSIGN ldo_data->* TO <lt_itab>.
  lo_table  ?= cl_abap_structdescr=>describe_by_data_ref( ldo_data ).
  lo_struct ?= lo_table->get_table_line_type( ).
  lt_comp = lo_struct->components.
*
  DATA: l_row_num TYPE numc3,
        l_parent_num TYPE numc3,
        l_item_num TYPE numc3,
        l_schl_num TYPE numc3,
        l_old_posnr TYPE posnr.

  l_item_num = 0.

  LOOP AT lt_vbdpa INTO ls_item_detail.
*
    IF sy-tabix EQ 1 OR l_old_posnr NE ls_item_detail-posnr.
      l_schl_num = 0.
      l_parent_num = 0.
      l_item_num = l_item_num + 1.
      l_row_num = l_item_num.
      l_old_posnr = ls_item_detail-posnr..
    ELSE.
* New schedule line
      l_schl_num = l_schl_num + 1.
      l_parent_num = l_item_num.
      l_row_num = l_schl_num.
    ENDIF.

    LOOP AT lt_comp INTO ls_comp_a.
      ASSIGN COMPONENT ls_comp_a-name OF STRUCTURE ls_item_detail TO <lo_field>.

      gs_vars-var_code = ls_comp_a-name.
      gs_vars-value = <lo_field>.
      gs_vars-row_num = l_row_num.
      gs_vars-parent_row_num = l_parent_num.
      APPEND gs_vars TO gt_vars.
    ENDLOOP.
*
  ENDLOOP.

Instead of printing data, call Floe API

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
*&---------------------------------------------------------------------*
*&      Form  print_data
*&---------------------------------------------------------------------*
FORM print_data.

  DATA:
    ls_outputparams TYPE sfpoutputparams,
    ls_docparams    TYPE sfpdocparams,
    lv_device       TYPE output_device.

  DATA: lt_mess TYPE bapiret2_t,
        ls_mess TYPE bapiret2.

* Get output parameters
  PERFORM get_output_params CHANGING ls_outputparams
                                     ls_docparams
                                     lv_device.
  CHECK <gv_returncode> IS INITIAL.

* Fill recipient
  gs_rec_email-email = gs_nast-email_addr.
  gs_rec_email-type = '1'.
  APPEND gs_rec_email TO gt_rec_emails.

* Call Floe interface.
  CALL FUNCTION '/FLOE/EMAIL_OUT' DESTINATION 'DV1CLNT800'
    EXPORTING
      im_etype            = tnapr-fonam
      im_elang            = gv_language
      im_document         = <gs_vbdka>-vbeln
      im_rec_emails       = gt_rec_emails
      im_variables        = gt_vars
      im_send_immediately = 'X'
    IMPORTING
      ex_subrc      = <gv_returncode>
      ex_mess       = lt_mess.

  LOOP AT lt_mess INTO ls_mess.
    CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
      EXPORTING
        msg_arbgb = ls_mess-id
        msg_nr    = ls_mess-number
        msg_ty    = ls_mess-type
        msg_v1    = ls_mess-message_v1
        msg_v2    = ls_mess-message_v2
        msg_v3    = ls_mess-message_v3
        msg_v4    = ls_mess-message_v4
      EXCEPTIONS
        OTHERS    = 0.
  ENDLOOP.

ENDFORM.                    " print_data