cancel
Showing results for 
Search instead for 
Did you mean: 

SmartForms passing tables with interface

Former Member
0 Kudos

Hello all,

I am working converting out Picklist from SAPScript to SmartForms. Right now the picklist is using 4-5 different tables and a few database structures. My question is should I continue to use these tables and structures (passing them in via the interface) or should I, in the print program, create an internal table that holds all of the needed fields.

I am also wondering if somebody could email me or post the code for the standard print program for /SMB40/SDPIK_L so that I can see an example.

Regards,

Davis

Accepted Solutions (1)

Accepted Solutions (1)

ferry_lianto
Active Contributor
0 Kudos

Hi Davis,

Send and please check your email.

Regards,

Ferry Lianto

Former Member
0 Kudos

Thank you so much for your help!

Answers (3)

Answers (3)

ferry_lianto
Active Contributor
0 Kudos

Hi Davis,

Please update your BC with your email address so that I can send the snapshots.

Regards,

Ferry Lianto

Former Member
0 Kudos

I have done that, thanks a lot!

Regards,

Davis

ferry_lianto
Active Contributor
0 Kudos

Hi Davis,

You can copy the above print program and modify to meet your requirement to add your own internal table which holds all needed fields. Also you can add additioal logic as well.

Once changes are done, then you can assign the custom print program to the output type configuration via transaction V/38.

Regards,

Ferry Lianto

Former Member
0 Kudos

Ferry, I am sorry for all of the questions/favors.

Is there any way for you to do a screen shot of the form interface and global definitions for me and post it or email it to aaronsap@gmail.com I want to see what is being passed.

Regards,

Davis

ferry_lianto
Active Contributor
0 Kudos

Hi Davis,

Please check this print program /SMB40/RVADEK01 for Smartform /SMB40/SDPIK_L. Here we go ...


*----------------------------------------------------------------------*
* Print of pickinglist for one single delivery note with Smart Form
*----------------------------------------------------------------------*
REPORT /bpr3pf/rvadek01 LINE-COUNT 100 MESSAGE-ID vn.

TABLES: vbco3,                         "Communicationarea for view
        vblkk,                         "Headerview
        vblkp,                         "Itemview
        ltak,                          "Transportauftrag
        adrs,                          "Communicationarea for Address
        riserls,                       "Serialnumbers
        komser,                        "Communicationarea Serialnumbers
        tvst, tvstt,                   "Shipping point
        vbkok, vbpok.

TABLES: nast,                          "Messages
        *nast,                         "Messages
        tnapr,                         "Programs & Forms
        itcpo,                         "Communicationarea for Spool
        arc_params,                    "Archive parameters
        toa_dara,                      "Archive parameters
        addr_key.                      "Adressnumber for ADDRESS

TYPE-POOLS szadr.

* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

DATA: retcode     LIKE sy-subrc,       "Returncode
      xvbeln      LIKE likp-vbeln,
      xkomau      LIKE likp-vbeln,
      xscreen(1)  TYPE c.              "Output on printer or screen

DATA: BEGIN OF tvblkp OCCURS 0.        "Internal table for items
        INCLUDE STRUCTURE vblkp.
DATA: END OF tvblkp.

DATA: BEGIN OF tsernr OCCURS 0.        "Internal table for serialnumbers
        INCLUDE STRUCTURE riserls.
DATA: END OF tsernr.

DATA: BEGIN OF tsernr_print OCCURS 0.
        INCLUDE STRUCTURE komser.
DATA: END   OF tsernr_print.

DATA:  BEGIN OF tltap OCCURS 50.       "TA-Positionen
        INCLUDE STRUCTURE ltap.
        INCLUDE STRUCTURE ltap1.
DATA:  END OF tltap.

DATA: BEGIN OF svblkp.
        INCLUDE STRUCTURE vblkp.
DATA: END OF svblkp.

* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

INCLUDE /smb40/vblpdata.
*include vblpdata.
INCLUDE /smb40/vbfadata.
*include vbfadata.
INCLUDE /smb40/vbukdata.
*include vbukdata.
INCLUDE /smb40/vbupdata.
*include vbupdata.
INCLUDE /smb40/vbbddata.
*include vbbddata.
INCLUDE /smb40/vbpadata.
*include vbpadata.
INCLUDE /smb40/sadrdata.
*include sadrdata.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

*---------------------------------------------------------------------*
*       FORM ENTRY                                                    *
*---------------------------------------------------------------------*
*       Steuerung des Drucks                                          *
*---------------------------------------------------------------------*
FORM entry USING return_code us_screen.

  CLEAR retcode.
  xscreen = us_screen.

  PERFORM processing USING us_screen.
  IF retcode NE 0.
    return_code = 1.
  ELSE.
* Kommimengen an Lieferungen zurückgeben, aber nicht bei Druckansicht
    IF xscreen = ' '.
      PERFORM delivery_update.
    ENDIF.
    return_code = 0.
  ENDIF.

ENDFORM.                    "entry

*---------------------------------------------------------------------*
*       FORM PROCESSING                                               *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  PROC_SCREEN                                                   *
*---------------------------------------------------------------------*
FORM processing USING proc_screen.

  REFRESH: xlips,
           xvbfa,
           xvbuk,
           xvbup,
           yvbfa,
           yvbuk,
           yvbup.

  PERFORM get_data.
  CHECK retcode = 0.
  PERFORM get_comm USING proc_screen tvst-aland.
  CHECK retcode = 0.
  PERFORM user_exit1.
  PERFORM smartform_print.
  CHECK retcode = 0.


ENDFORM.                    "processing

***********************************************************************
*       S U B R O U T I N E S                                         *
***********************************************************************

*---------------------------------------------------------------------*
*       FORM DELIVERY_UPDATE                                          *
*---------------------------------------------------------------------*
*       Ergänzen Lieferung um Kommissionierinformation                *
*---------------------------------------------------------------------*

* Ergänzen der Lieferungen um Kommissionierinformation
FORM delivery_update.

  DATA: BEGIN OF hvbpok OCCURS 10.     "Lieferpositionen Kommiss.
          INCLUDE STRUCTURE vbpok.
  DATA: END OF hvbpok.

  DATA: BEGIN OF sav_nast.
          INCLUDE STRUCTURE nast.
  DATA: END OF sav_nast.

* DATA: SYNC_FLAG TYPE C.             "synchrone Verbuchung?

* Füllen Lieferkopfdaten für Kommi-Update
  vbkok-vbeln_vl = xvbeln.
  vbkok-vbeln = vblkk-komau.

* Füllen Positionsdaten zu Liefernr.
  LOOP AT tvblkp.
    hvbpok-vbeln_vl = tvblkp-vbeln.
    hvbpok-posnr_vl = tvblkp-posnr.
    hvbpok-posnn = tvblkp-posnr.
    hvbpok-vbeln = vblkk-komau.
    hvbpok-vbtyp_n = 'Q'.
    hvbpok-pikmg = tvblkp-komng.
    hvbpok-meins = tvblkp-meins.
    hvbpok-ndifm = 0.
    hvbpok-taqui = ' '.
    hvbpok-charg = tvblkp-charg.
    hvbpok-matnr = tvblkp-matnr.
    hvbpok-brgew = tvblkp-brgew.
    hvbpok-gewei = tvblkp-gewei.
    hvbpok-volum = tvblkp-volum.
    hvbpok-voleh = tvblkp-voleh.
    hvbpok-orpos = 0.
    APPEND hvbpok.
  ENDLOOP.

* IF NAST-VSZTP <> 4.
*    SYNC_FLAG = 'X'.
* ELSE.
*    SYNC_FLAG = ' '.
* ENDIF.

  sav_nast = nast.
  CALL FUNCTION 'SD_DELIVERY_UPDATE_PICKING'
    EXPORTING
      nicht_sperren = 'X'
      vbkok_wa      = vbkok
      aufrufer_t    = 'X'
    TABLES
      vbpok_tab     = hvbpok.
  nast = sav_nast.

* Freigabe an Datenbank
* COMMIT WORK.

ENDFORM.                    "delivery_update


*---------------------------------------------------------------------*
*       FORM get_comm                                               *
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
*  -->  US_SCREEN  Output on screen                                   *
*                  ' ' = printer                                      *
*                  'X' = screen                                       *
*  -->  US_COUNTRY County for telecommunication and SET COUNTRY       *
*---------------------------------------------------------------------*

FORM get_comm USING us_screen us_country.
  DATA: lvs_itcpo         TYPE   itcpo,
        lvf_device(30)    TYPE   c,
        lvf_dialog(1)     TYPE   c   VALUE ' ',
        lvs_recipient     LIKE   swotobjid,
        lvs_sender        LIKE   swotobjid,
        lvs_snast         TYPE   snast,
        lvf_program       LIKE   sy-repid,
        lvs_comm_type     TYPE   ad_comm,
        lvs_comm_values   TYPE   szadr_comm_values.


* reset return code
  retcode = 0.


* if there is a communication strategy used ...
  IF NOT nast-tcode IS INITIAL.

*   ... use stratagy to get communication type
    CALL FUNCTION 'ADDR_GET_NEXT_COMM_TYPE'
         EXPORTING
              strategy           = nast-tcode
*             ADDRESS_TYPE       =
*             ADDRESS_NUMBER     = VBDKA-ADRNR
*             PERSON_NUMBER      = VBDKA-ADRNP
              address_number     = addr_key-addrnumber
              person_number      = addr_key-persnumber
         IMPORTING
              comm_type          = lvs_comm_type
              comm_values        = lvs_comm_values
*        TABLES
*             STRATEGY_TABLE     =
         EXCEPTIONS
              address_not_exist  = 1
              person_not_exist   = 2
              no_comm_type_found = 3
              internal_error     = 4
              parameter_error    = 5
              OTHERS             = 6.
    IF sy-subrc <> 0.
      retcode = sy-subrc.
      syst-msgty = 'E'.
      PERFORM protocol_update.
    ENDIF.

  ENDIF.


* convert communication data
  MOVE-CORRESPONDING nast TO lvs_snast.
  MOVE sy-repid           TO lvf_program.
  CALL FUNCTION 'CONVERT_COMM_TYPE_DATA'
       EXPORTING
            pi_comm_type              = lvs_comm_type
            pi_comm_values            = lvs_comm_values
            pi_screen                 = us_screen
*           PI_NEWID                  =
            pi_country                = us_country
            pi_repid                  = lvf_program
            pi_snast                  = lvs_snast
       IMPORTING
            pe_itcpo                  = lvs_itcpo
            pe_device                 = lvf_device
            pe_mail_recipient         = lvs_recipient
            pe_mail_sender            = lvs_sender
       EXCEPTIONS
            comm_type_not_supported   = 1
            recipient_creation_failed = 2
            sender_creation_failed    = 3
            OTHERS                    = 4.
  IF sy-subrc <> 0.
    retcode = sy-subrc.
    syst-msgty = 'E'.
    PERFORM protocol_update.
  ENDIF.

  CHECK retcode EQ 0.

* if there is no communication type
  IF  lvs_comm_type IS INITIAL.
*   set device
    CASE nast-nacha.
      WHEN '1'.
        lvf_device = 'PRINTER'.
      WHEN '2'.
        lvf_device = 'TELEFAX'.
        lvs_itcpo-tdtelenum = nast-telfx.
        IF nast-tland IS INITIAL.
          lvs_itcpo-tdteleland = us_country.
        ELSE.
          lvs_itcpo-tdteleland = nast-tland.
        ENDIF.
        lvs_itcpo-tdsenddate = nast-vsdat.
        lvs_itcpo-tdsendtime = nast-vsura.
        lvs_itcpo-tdfaxuser  = nast-usnam.
      WHEN '3'.
        lvf_device = 'TELETEX'.
        lvs_itcpo-tdtelenum = nast-teltx.
        IF nast-tland IS INITIAL.
          lvs_itcpo-tdteleland = us_country.
        ELSE.
          lvs_itcpo-tdteleland = nast-tland.
        ENDIF.
        lvs_itcpo-tdsenddate = nast-vsdat.
        lvs_itcpo-tdsendtime = nast-vsura.
      WHEN '4'.
        lvf_device = 'TELEX'.
        lvs_itcpo-tdtelenum = nast-telx1.
        IF nast-tland IS INITIAL.
          lvs_itcpo-tdteleland = us_country.
        ELSE.
          lvs_itcpo-tdteleland = nast-tland.
        ENDIF.
        lvs_itcpo-tdsenddate = nast-vsdat.
        lvs_itcpo-tdsendtime = nast-vsura.
      WHEN OTHERS.
        lvf_device = 'PRINTER'.
    ENDCASE.
  ENDIF.

* fill structure itcpo
  itcpo = lvs_itcpo.
  SET COUNTRY us_country.
*  include rvadopfo.

ENDFORM.                    "get_comm


*---------------------------------------------------------------------*
*       FORM GET_DATA                                                 *
*---------------------------------------------------------------------*
*       General provision of data for the form                        *
*---------------------------------------------------------------------*

FORM get_data.

  DATA: vblkp_lines      TYPE p.

* Beschaffen View
  xvbeln = nast-objky.
  CALL FUNCTION 'RV_DELIVERY_PICK_VIEW'
    EXPORTING
      vbeln     = xvbeln
      zweck     = 'D'
      spras     = nast-spras
    IMPORTING
      vblkk_wa  = vblkk
    TABLES
      vblkp_tab = tvblkp
    EXCEPTIONS
      OTHERS    = 1.
  IF sy-subrc NE 0.
    PERFORM protocol_update.
  ENDIF.

* gibt es zu kommissionierende Positionen, ggf. sortieren
  DESCRIBE TABLE tvblkp LINES vblkp_lines.
  IF vblkp_lines GT 0.

* Nummernvergabe Kommissionierauftrag
    CLEAR vblkk-komau.
    CALL FUNCTION 'NUMBER_GET_NEXT'
      EXPORTING
        nr_range_nr = '01'
        object      = 'SD_PICKING'
      IMPORTING
        number      = vblkk-komau
      EXCEPTIONS
        OTHERS      = 1.
    IF sy-subrc NE 0.
    ENDIF.

    IF vblkk-komau IS INITIAL.
      vblkk-komau = sy-datum+2.
      vblkk-komau+6(4) = sy-uzeit(4).
    ENDIF.

    PERFORM sort_pick_list.
    retcode = 0.
  ELSE.
    retcode = 4.
    syst-msgid = 'VN'.
    syst-msgno = '202'.
    syst-msgty = 'E'.
    syst-msgv1 = vblkk-vbeln.
    PERFORM protocol_update.
    CHECK 1 = 2.
  ENDIF.

* Lesen Versandstelle
  IF vblkk-vstel EQ space.
    CLEAR: tvst, tvstt.
  ELSE.
    SELECT SINGLE * FROM tvst WHERE vstel EQ vblkk-vstel.
    IF sy-subrc NE 0.
      CLEAR tvst.
      syst-msgid = 'VN'.
      syst-msgno = '203'.
      syst-msgty = 'E'.
      syst-msgv1 = 'TVST'.
      syst-msgv2 = syst-subrc.
      PERFORM protocol_update.
    ENDIF.
    SELECT SINGLE * FROM tvstt WHERE spras EQ nast-spras
                                 AND vstel EQ vblkk-vstel.
    IF sy-subrc NE 0.
      CLEAR tvstt.
      syst-msgid = 'VN'.
      syst-msgno = '203'.
      syst-msgty = 'E'.
      syst-msgv1 = 'TVSTT'.
      syst-msgv2 = syst-subrc.
      PERFORM protocol_update.
    ENDIF.
  ENDIF.

ENDFORM.                    "get_data

*---------------------------------------------------------------------*
*       FORM GET_SERIAL_NO                                            *
*---------------------------------------------------------------------*
*       In this routine the serialnumbers are fetched from the        *
*       database.                                                     *
*---------------------------------------------------------------------*

FORM get_serial_no.

  REFRESH tsernr.
  REFRESH tsernr_print.
  CHECK vblkp-anzsn > 0.
* Read the Serialnumbers of a Position.
  CALL FUNCTION 'SERIAL_LS_PRINT'
    EXPORTING
      vbeln  = vblkp-vbeln
      posnr  = vblkp-posnr
    TABLES
      iserls = tsernr.

* Process the stringtable for Printing.
  CALL FUNCTION 'PROCESS_SERIALS_FOR_PRINT'
    EXPORTING
      i_boundary_left             = '(_'
      i_boundary_right            = '_)'
      i_sep_char_strings          = ',_'
      i_sep_char_interval         = '_-_'
      i_use_interval              = 'X'
      i_boundary_method           = 'C'
      i_line_length               = 50
      i_no_zero                   = 'X'
      i_alphabet                  = sy-abcde
      i_digits                    = '0123456789'
      i_special_chars             = '-'
      i_with_second_digit         = ' '
    TABLES
      serials                     = tsernr
      serials_print               = tsernr_print
    EXCEPTIONS
      boundary_missing            = 01
      interval_separation_missing = 02
      length_to_small             = 03
      internal_error              = 04
      wrong_method                = 05
      wrong_serial                = 06
      two_equal_serials           = 07
      serial_with_wrong_char      = 08
      serial_separation_missing   = 09.

  IF sy-subrc NE 0.
    PERFORM protocol_update.
  ENDIF.

ENDFORM.                    "get_serial_no
*---------------------------------------------------------------------*
*       FORM SMARTFORM_PRINT
*---------------------------------------------------------------------*

FORM smartform_print.

  DATA: e_werks LIKE tvblkp-werks VALUE ' ',
        e_lgort LIKE tvblkp-lgort VALUE ' ',
        e_lgnum LIKE tvblkp-lgnum VALUE ' ',
        e_mbdat LIKE tvblkp-mbdat VALUE IS INITIAL.
  DATA: lf_fm_name            TYPE rs38l_fnam.
  DATA: ls_control_param      TYPE ssfctrlop.
  DATA: ls_composer_param     TYPE ssfcompop.
  DATA: ls_recipient          TYPE swotobjid.
  DATA: ls_sender             TYPE swotobjid.
  DATA: lf_formname           TYPE tdsfname.
  DATA: ls_addr_key           LIKE addr_key.

  CLEAR retcode.
*  nast_key = objky.


  PERFORM set_print_param USING      ls_addr_key
                          CHANGING ls_control_param
                                   ls_composer_param
                                   ls_recipient
                                   ls_sender
                                   retcode.
*Get the Smart Form name.
  IF NOT tnapr-sform IS INITIAL.
    lf_formname = tnapr-sform.
  ELSE.
    MESSAGE e001(/smb40/ssfcomposer).
  ENDIF.

* determine smartform function module for invoice
  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
       EXPORTING  formname           = lf_formname
*                 variant            = ' '
*                 direct_call        = ' '
       IMPORTING  fm_name            = lf_fm_name
       EXCEPTIONS no_form            = 1
                  no_function_module = 2
                  OTHERS             = 3.
  IF sy-subrc <> 0.
*   error handling
    retcode = sy-subrc.
    IF sy-subrc = 1.
      MESSAGE e001(/smb40/ssfcomposer).
    ENDIF.
    IF sy-subrc = 2.
      MESSAGE e002(/smb40/ssfcomposer).
    ENDIF.
    PERFORM protocol_update.
  ENDIF.



  CALL FUNCTION lf_fm_name
    EXPORTING
       archive_index              = toa_dara
*   ARCHIVE_INDEX_TAB          =
       archive_parameters         = arc_params
       control_parameters         = ls_control_param
*   MAIL_APPL_OBJ              =
       mail_recipient             = ls_recipient
       mail_sender                = ls_sender
       output_options             = ls_composer_param
       user_settings              = ' '
       vblkk                     = vblkk
       TABLES
            tvblkp                     = tvblkp
* IMPORTING
*   DOCUMENT_OUTPUT_INFO       =
*   JOB_OUTPUT_INFO            =
*   JOB_OUTPUT_OPTIONS         =
EXCEPTIONS
 formatting_error           = 1
 internal_error             = 2
 send_error                 = 3
 user_canceled              = 4
 OTHERS                     = 5
            .
  IF sy-subrc <> 0.
    retcode = sy-subrc.
    PERFORM protocol_update.
* get SmartForm protocoll and store it in the NAST protocoll
    PERFORM add_smfrm_prot.
  ENDIF.
ENDFORM.                    "smartform_print


*---------------------------------------------------------------------*
*       FORM PROTOCOL_UPDATE                                          *
*---------------------------------------------------------------------*
*       The messages are collected for the processing protocol.       *
*---------------------------------------------------------------------*

FORM protocol_update.

  CHECK xscreen = space.
  CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
    EXPORTING
      msg_arbgb = syst-msgid
      msg_nr    = syst-msgno
      msg_ty    = syst-msgty
      msg_v1    = syst-msgv1
      msg_v2    = syst-msgv2
      msg_v3    = syst-msgv3
      msg_v4    = syst-msgv4
    EXCEPTIONS
      OTHERS    = 1.

ENDFORM.                    "protocol_update

*---------------------------------------------------------------------*
*       FORM SENDER                                                   *
*---------------------------------------------------------------------*
*       This routine determines the address of the sender (Table VBUR)*
*---------------------------------------------------------------------*

FORM user_exit1.

ENDFORM.                                                    "user_exit1
INCLUDE /smb40/mv50bfz1.
*include mv50bfz1.
*&---------------------------------------------------------------------*
*&      Form  set_print_param
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_LS_ADDR_KEY  text
*      <--P_LS_CONTROL_PARAM  text
*      <--P_LS_COMPOSER_PARAM  text
*      <--P_LS_RECIPIENT  text
*      <--P_LS_SENDER  text
*      <--P_RETCO  text
*----------------------------------------------------------------------*
FORM set_print_param USING    is_addr_key LIKE addr_key
                     CHANGING cs_control_param TYPE ssfctrlop
                              cs_composer_param TYPE ssfcompop
                              cs_recipient TYPE  swotobjid
                              cs_sender TYPE  swotobjid
                              cf_retcode TYPE sy-subrc.

  DATA: ls_itcpo     TYPE itcpo.
  DATA: lf_repid     TYPE sy-repid.
  DATA: lf_device    TYPE tddevice.
  DATA: ls_recipient TYPE swotobjid.
  DATA: ls_sender    TYPE swotobjid.

  lf_repid = sy-repid.
  IF itcpo IS INITIAL.
    CALL FUNCTION 'WFMC_PREPARE_SMART_FORM'
      EXPORTING
        pi_nast       = nast
        pi_addr_key   = is_addr_key
        pi_repid      = lf_repid
      IMPORTING
        pe_returncode = cf_retcode
        pe_itcpo      = ls_itcpo
        pe_device     = lf_device
        pe_recipient  = cs_recipient
        pe_sender     = cs_sender.

    IF cf_retcode = 0.
      MOVE-CORRESPONDING ls_itcpo TO cs_composer_param.
*   CS_CONTROL_PARAM-NO_OPEN
*   CS_CONTROL_PARAM-NO_CLOSE
      cs_control_param-device      = lf_device.
      cs_control_param-no_dialog   = 'X'.
      cs_control_param-preview     = xscreen.
      cs_control_param-getotf      = ls_itcpo-tdgetotf.
      cs_control_param-langu       = nast-spras.
*   CS_CONTROL_PARAM-REPLANGU1
*   CS_CONTROL_PARAM-REPLANGU2
*   CS_CONTROL_PARAM-REPLANGU3
*   CS_CONTROL_PARAM-STARTPAGE
    ENDIF.
  ELSE.
    MOVE-CORRESPONDING itcpo TO cs_composer_param.
*   CS_CONTROL_PARAM-NO_OPEN
*   CS_CONTROL_PARAM-NO_CLOSE
    cs_control_param-device      = lf_device.
    cs_control_param-no_dialog   = 'X'.
    cs_control_param-preview     = xscreen.
    cs_control_param-getotf      = itcpo-tdgetotf.
    cs_control_param-langu       = nast-spras.
*   CS_CONTROL_PARAM-REPLANGU1
*   CS_CONTROL_PARAM-REPLANGU2
*   CS_CONTROL_PARAM-REPLANGU3
*   CS_CONTROL_PARAM-STARTPAGE

  ENDIF.

ENDFORM.                               " set_print_param
**&---------------------------------------------------------------------
*
**&      Form  protocol_update_i
**&---------------------------------------------------------------------
*
**       text
**----------------------------------------------------------------------
*
**  -->  p1        text
**  <--  p2        text
**----------------------------------------------------------------------
*
*form protocol_update_i.
*  check xscreen = space.
*  call function 'NAST_PROTOCOL_UPDATE'
*       exporting
*            msg_arbgb = syst-msgid
*            msg_nr    = syst-msgno
*            msg_ty    = syst-msgty
*            msg_v1    = syst-msgv1
*            msg_v2    = syst-msgv2
*            msg_v3    = syst-msgv3
*            msg_v4    = syst-msgv4
*       exceptions
*            others    = 1.
*
*endform.                               " protocol_update_i
*&---------------------------------------------------------------------*
*&      Form  add_smfrm_prot
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM add_smfrm_prot.
  DATA: lt_errortab             TYPE tsferror.
  DATA: lf_msgnr                TYPE sy-msgno.
  DATA:  l_s_log                TYPE bal_s_log,
         p_loghandle            TYPE balloghndl,
         l_s_msg                TYPE bal_s_msg.

  FIELD-SYMBOLS: <fs_errortab>  TYPE LINE OF tsferror.

* get smart form protocoll
  CALL FUNCTION 'SSF_READ_ERRORS'
    IMPORTING
      errortab = lt_errortab.

* add smartform protocoll to nast protocoll
  LOOP AT lt_errortab ASSIGNING <fs_errortab>.
    CLEAR lf_msgnr.
    lf_msgnr = <fs_errortab>-errnumber.
    CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
      EXPORTING
        msg_arbgb = <fs_errortab>-msgid
        msg_nr    = lf_msgnr
        msg_ty    = <fs_errortab>-msgty
        msg_v1    = <fs_errortab>-msgv1
        msg_v2    = <fs_errortab>-msgv2
        msg_v3    = <fs_errortab>-msgv3
        msg_v4    = <fs_errortab>-msgv4
      EXCEPTIONS
        OTHERS    = 1.
  ENDLOOP.
* open the application log
  l_s_log-extnumber    = sy-uname.

  CALL FUNCTION 'BAL_LOG_CREATE'
    EXPORTING
      i_s_log      = l_s_log
    IMPORTING
      e_log_handle = p_loghandle
    EXCEPTIONS
      OTHERS       = 1.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  LOOP AT lt_errortab ASSIGNING <fs_errortab>.
    MOVE-CORRESPONDING <fs_errortab> TO l_s_msg.
    CALL FUNCTION 'BAL_LOG_MSG_ADD'
      EXPORTING
        i_log_handle = p_loghandle
        i_s_msg      = l_s_msg
      EXCEPTIONS
        OTHERS       = 1.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
  ENDLOOP.

  CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

ENDFORM.                               " add_smfrm_prot

Regards,

Ferry Lianto

Former Member
0 Kudos

Ferry, thank you so much for that print program. I really wish that I could import the preconfigured SmartForms but I can't so I am not even able to see the print programs.

Do you have any thoughts on using the existing tables/structures instead of creating my own internal tables/structures?

Regards,

Davis