Print out every delivery

Dear All.
Till this day the duty-form for a company were performed through a
special Form Program, it is performed via processing routines.
The first Form Routine's name is entry.
Form was printed-out for each Transport up to now.
Current Requirements are for next time as follows:
Printing out one form for every delivery (shipment) instead of
for each Transport as so far. Please notice one Transport may
consist of many deliveries (Shipment). 1 Transport : n Shipment.
DATA:
      lc_wa_usrdata  TYPE /Z2a/ty_lw_usrdata.
INCLUDE rvadtabl.
SET EXTENDED CHECK OFF.
TABLES: vbpla, thead, ttxer, ttxit, t005, vbddl, stxh, sadr."SADR40A
INCLUDE vttkdata.                      "Shipment Header
INCLUDE vttsdata.                      "Shipment Segment
INCLUDE vttpdata.                      "Shipment Items
INCLUDE vbpadata.                      "Partner
INCLUDE vtfadata.                      "Flow
INCLUDE sadrdata.                      "Address
INCLUDE vtlfdata.                      "Delivery Selection
INCLUDE vsedata.                       "shipping units
INCLUDE rv56acom.                      "I/O-Structure
SET EXTENDED CHECK ON.
TABLES: /Z2a/tv_schein.
FORM entry USING return_code us_screen.
  DATA: lf_retcode TYPE sy-subrc.
  screen = us_screen.
  PERFORM processing USING    us_screen
                     CHANGING lf_retcode.
  IF lf_retcode NE 0.
    return_code = 1.
  ELSE.
    return_code = 0.
  ENDIF.
ENDFORM.
FORM processing USING    proc_screen
                CHANGING cf_retcode.
  DATA: ls_print_data_to_read TYPE ledlv_print_data_to_read.
  DATA: ls_dlv_delnote        TYPE ledlv_delnote.
  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.
  DATA: ls_header             LIKE /Z2a/ss_pv_kopf.
  DATA: tb_daten              LIKE /Z2a/ss_pv_daten OCCURS 1.
  DATA: lc_va_lfnr            TYPE nrlevel.
  DATA: lc_va_year            TYPE char4.
  DATA: lc_va_keyseg_pv       TYPE /dca/p000_keyseg.
  DATA: lc_tb_bwdat_pv        TYPE /dca/p000_ty_tb_bwdat.
  DATA: lc_wa_bwdat_pv        TYPE /dca/p000_ty_wa_bwdat.
  DATA: lc_wa_bwm_res_pv      TYPE /Z2a/dat_cu_pvschein.
  DATA: lc_va_lifnr           TYPE kunnr.
  DATA: lc_va_nr              TYPE nrnr.
  DATA: lc_va_anz             TYPE /Z2a/anz_pv.
  DATA: lc_va_no              TYPE /Z2a/anz_kein_pv.
  DATA: lc_wa_pvschein        LIKE /Z2a/tv_schein.
  DATA: lc_va_line            LIKE sy-tabix.
  DATA: lc_va_flag_zoll       TYPE segal,
        lc_va_rqident         TYPE rspoid,
        lc_va_vsart           TYPE vsarttr,
        lc_va_tknum           TYPE tknum.
  DATA: lc_va_obj             TYPE nrobj.
  DATA: lc_va_printer         TYPE rspopname.
  DATA: lc_va_pv_kz           TYPE char4.
  DATA: lc_va_tplst           TYPE tplst.
* SmartForm from customizing table TNAPR
  lf_formname = tnapr-sform.
* determine print data
  PERFORM set_print_data_to_read USING    lf_formname
                                 CHANGING ls_print_data_to_read
                                 cf_retcode.
  IF cf_retcode = 0.
* select print data
    PERFORM get_data_pv TABLES   tb_daten
                        CHANGING ls_header
                                 lc_va_flag_zoll
                                 lc_va_vsart
                                 lc_va_tplst
                                 cf_retcode.
  ENDIF.
  lc_va_tknum = nast-objky.
  IF cf_retcode = 0.
  ELSE.
    PERFORM protocol_nast_update.
    cf_retcode = 4.
    EXIT.
  ENDIF.
  IF cf_retcode = 0.
* determine smartform function module for delivery note
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
         EXPORTING  formname           = lf_formname
         IMPORTING  fm_name            = lf_fm_name
         EXCEPTIONS no_form            = 1
                    no_function_module = 2
                    OTHERS             = 3.
    IF sy-subrc <> 0.
    ENDIF.
  ENDIF.
  DESCRIBE TABLE tb_daten LINES lc_va_line.
  IF lc_va_line <> 0.
    lc_va_pv_kz = 'JA'.
    SELECT SINGLE lifnr
      FROM vtpa
      INTO lc_va_lifnr
     WHERE vbeln = nast-objky
       AND parvw = 'YL'.
    lc_va_keyseg_pv = ls_header-kunnr.
    lc_va_keyseg_pv+10(10) = lc_va_lifnr.
    lc_va_keyseg_pv+20(2)  = lc_va_vsart.
    lc_va_keyseg_pv+22(4)  = lc_va_pv_kz.
    CALL FUNCTION '/ZTR/P000_MCDATA_FROM_'
         EXPORTING
              cv_va_keytyp = '/Z2a/KEY_CU_PVSCHEIN'
              cv_va_keyseg = lc_va_keyseg_pv
         TABLES
              cr_tb_bwdat  = lc_tb_bwdat_pv.
    IF lc_tb_bwdat_pv[] IS INITIAL.
      cf_retcode = 4.
    ELSE.
      LOOP AT lc_tb_bwdat_pv INTO lc_wa_bwdat_pv.
        lc_wa_bwm_res_pv = lc_wa_bwdat_pv-datseg.
        lc_va_obj = lc_wa_bwm_res_pv(10).
        lc_va_nr  = lc_wa_bwm_res_pv+10(2).
        lc_va_anz = lc_wa_bwm_res_pv+12(8).
        lc_va_printer  = lc_wa_bwm_res_pv+20(4).
        SELECT SINGLE pvno
          FROM /Z2a/tv_schein
          INTO lc_va_lfnr
         WHERE tknum = nast-objky.
        IF sy-subrc = 0.
        ELSE.
          CALL FUNCTION 'NUMBER_GET_NEXT'
            EXPORTING
          nr_range_nr                   = lc_va_nr
          object                        = lc_va_obj
           IMPORTING
             number                     = lc_va_lfnr
          IF sy-subrc <> 0.
          ENDIF.
        ENDIF.
      ENDLOOP.
    ENDIF.
*   call smartform delivery note
    ls_composer_param-tddest = lc_va_printer.
*    ls_control_param-device  = lc_va_printer.
    lc_va_year = sy-datum(4).
    PERFORM set_print_param USING    ls_addr_key
                                     lc_va_lfnr
                            CHANGING ls_control_param
                                     ls_composer_param
                                     ls_recipient
                                     ls_sender
                                     cf_retcode.
    lc_wa_usrdata-mandt  = sy-mandt.
    lc_wa_usrdata-udate  = sy-datum.
    lc_wa_usrdata-uzeit  = sy-uzeit.
    lc_wa_usrdata-usr    = sy-uname.
    lc_wa_usrdata-sysid  = sy-sysid.
    DO lc_va_anz TIMES.
      CALL FUNCTION lf_fm_name
           EXPORTING
                    archive_index        = toa_dara
                    archive_parameters   = arc_params
                    control_parameters   = ls_control_param
                    mail_recipient       = ls_recipient
                    mail_sender          = ls_sender
                    output_options       = ls_composer_param
                    user_settings        = ' '
                    ls_header            = ls_header
                    lc_va_lfnr           = lc_va_lfnr
                    lc_va_year           = lc_va_year
                    lc_va_tplst          = lc_va_tplst
                    lc_wa_usrdata        = lc_wa_usrdata
          TABLES
                    tb_daten             = tb_daten
         EXCEPTIONS formatting_error     = 1
                    internal_error       = 2
                    send_error           = 3
                    user_canceled        = 4
                    OTHERS               = 5.
      IF sy-subrc <> 0.
      ENDIF.
    ENDDO.
  ELSE.
    lc_va_pv_kz = 'NEIN'.
    SELECT SINGLE lifnr
      FROM vtpa
      INTO lc_va_lifnr
     WHERE vbeln = nast-objky
       AND parvw = 'YL'.
    lc_va_keyseg_pv = ls_header-kunnr.
    lc_va_keyseg_pv+10(10) = lc_va_lifnr.
    lc_va_keyseg_pv+20(2)  = lc_va_vsart.
    lc_va_keyseg_pv+22(4)  = lc_va_pv_kz.
    CALL FUNCTION '/ZTR/P000_MCDATA_FROM_'
         EXPORTING
              cv_va_keytyp = '/Z2a/KEY_CU_PVSCHEIN'
              cv_va_keyseg = lc_va_keyseg_pv
         TABLES
              cr_tb_bwdat  = lc_tb_bwdat_pv.
    IF lc_tb_bwdat_pv[] IS INITIAL.
      cf_retcode = 4.
    ELSE.
      LOOP AT lc_tb_bwdat_pv INTO lc_wa_bwdat_pv.
        lc_wa_bwm_res_pv = lc_wa_bwdat_pv-datseg.
        lc_va_obj = lc_wa_bwm_res_pv(10).
        lc_va_nr  = lc_wa_bwm_res_pv+10(2).
        lc_va_anz = lc_wa_bwm_res_pv+12(8).
        lc_va_printer  = lc_wa_bwm_res_pv+20(4).
        SELECT SINGLE pvno
          FROM /Z2a/tv_schein
          INTO lc_va_lfnr
         WHERE tknum = nast-objky.
        IF sy-subrc = 0.
          UPDATE /Z2a/tv_schein
          SET flag_pv = ' '
          WHERE tknum = nast-objky.
        ELSE.
* laufende nummer füllen, bei keinen PV-Teilen Nummernkreis 99
          CALL FUNCTION 'NUMBER_GET_NEXT'
            EXPORTING
          nr_range_nr                   = lc_va_nr
          object                        = lc_va_obj
*    QUANTITY                      = '1'
*   SUBOBJECT                     = ' '
*   TOYEAR                        = '0000'
*   IGNORE_BUFFER                 = ' '
           IMPORTING
             number                     = lc_va_lfnr
*   QUANTITY                      =
*   RETURNCODE                    =
* EXCEPTIONS
*   INTERVAL_NOT_FOUND            = 1
*   NUMBER_RANGE_NOT_INTERN       = 2
*   OBJECT_NOT_FOUND              = 3
*   QUANTITY_IS_0                 = 4
*   QUANTITY_IS_NOT_1             = 5
*   INTERVAL_OVERFLOW             = 6
*   BUFFER_OVERFLOW               = 7
*   OTHERS                        = 8
          IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
        ENDIF.
      ENDLOOP.
      lc_va_year = sy-datum(4).
      ls_composer_param-tddest = lc_va_printer.
      PERFORM set_print_param USING    ls_addr_key
                                       lc_va_lfnr
                              CHANGING ls_control_param
                                       ls_composer_param
                                       ls_recipient
                                       ls_sender
                                       cf_retcode.
      lc_wa_usrdata-mandt  = sy-mandt.
      lc_wa_usrdata-udate  = sy-datum.
      lc_wa_usrdata-uzeit  = sy-uzeit.
      lc_wa_usrdata-usr    = sy-uname.
      lc_wa_usrdata-sysid  = sy-sysid.
      DO lc_va_anz TIMES.
        CALL FUNCTION lf_fm_name
             EXPORTING
                      archive_index        = toa_dara
                      archive_parameters   = arc_params
                      control_parameters   = ls_control_param
                      mail_recipient       = ls_recipient
                      mail_sender          = ls_sender
                      output_options       = ls_composer_param
                      user_settings        = ' '
                      ls_header            = ls_header
                      lc_va_lfnr           = lc_va_lfnr
                      lc_va_year           = lc_va_year
                      lc_va_tplst          = lc_va_tplst
                      lc_wa_usrdata        = lc_wa_usrdata
            TABLES
                      tb_daten             = tb_daten
           EXCEPTIONS formatting_error     = 1
                      internal_error       = 2
                      send_error           = 3
                      user_canceled        = 4
                      OTHERS               = 5.
        IF sy-subrc <> 0.
        ENDIF.
      ENDDO.
    ENDIF.
  ENDIF.
  SELECT SINGLE *
    FROM /Z2a/tv_schein
    INTO lc_wa_pvschein
   WHERE tknum = nast-objky.
  IF sy-subrc = 0.
  ELSE.
    IF NOT lc_va_lfnr IS INITIAL.
      lc_wa_pvschein-mandt = sy-mandt.
      lc_wa_pvschein-tknum = nast-objky.
      INSERT INTO /Z2a/tv_schein
      VALUES lc_wa_pvschein.
      UPDATE /Z2a/tv_schein SET
      pvno  = lc_va_lfnr
      vsart = lc_va_vsart
      exti1 = ls_header-schiffname
      signi = ls_header-siegel
      flag_zoll = lc_va_flag_zoll
      exti2 = ls_header-contnr
      lifex = ls_header-mbcnr
      dalen = ls_header-dalen
      dptbg = ls_header-dptbg
      kunnr = ls_header-kunnr
      add03 = ls_header-add03
      parnr = lc_va_lifnr
      datum_druck = sy-datum
      uzeit_druck = sy-uzeit
      ernam_druck = sy-ucomm
      WHERE tknum = nast-objky.
      IF tb_daten IS INITIAL.
        UPDATE /Z2a/tv_schein SET
       flag_pv = ' '
       WHERE tknum = nast-objky.
      ELSE.
        UPDATE /Z2a/tv_schein SET
        flag_pv = 'X'.
      ENDIF.
    ENDIF.
  ENDIF.
* get SmartForm protocoll and store it in the NAST protocoll
* PERFORM ADD_SMFRM_PROT.                       DEL_HP_335958
ENDFORM.
FORM get_data_pv TABLES   lc_tb_daten
                 CHANGING cs_header TYPE /Z2a/ss_pv_kopf
                          lc_va_flag_zoll TYPE segal
                          lc_va_vsart TYPE vsarttr
                          lc_va_tplst TYPE tplst
                          cf_retcode.
  TYPES: BEGIN OF ty_wa_vbeln,
         vbeln TYPE vbeln_vl,
         END OF ty_wa_vbeln,
         ty_tb_vbeln TYPE STANDARD TABLE OF ty_wa_vbeln
                     WITH DEFAULT KEY
                     INITIAL SIZE 0,
         ty_wa_lips LIKE lips,
         ty_tb_lips TYPE STANDARD TABLE OF ty_wa_lips
                    WITH DEFAULT KEY
                    INITIAL SIZE 0.
  DATA: lc_tb_cond  LIKE /Z2a/ss_pv_daten OCCURS 1.
  DATA: lc_wa_daten TYPE /Z2a/ss_pv_daten.
  DATA: lc_wa_cond  TYPE /Z2a/ss_pv_daten.
  DATA: lc_va_tknum TYPE tknum,
        lc_tb_lips  TYPE ty_tb_lips,
        lc_wa_lips  TYPE ty_wa_lips,
        lc_va_kunnr TYPE kunnr,
        lc_va_pvvkz TYPE /Z2a/pvvkz,
        lc_va_exprf TYPE exprf,
        lc_va_matnr TYPE matnr,
        lc_va_menge TYPE lfimg.
  DATA: lc_tb_vbeln TYPE ty_tb_vbeln,
        lc_wa_vbeln TYPE ty_wa_vbeln,
        lc_va_land1 TYPE land1,
        lc_va_lifnr TYPE lifnr.
  DATA: lc_va_exnum TYPE exnum.
  DATA: lc_va_keyseg TYPE /dca/p000_keyseg.
  DATA: lc_tb_bwdat  TYPE /dca/p000_ty_tb_bwdat.
  DATA: lc_wa_bwdat  TYPE /dca/p000_ty_wa_bwdat.
  DATA: lc_wa_bwm_result TYPE /Z2a/dat_cu_pvabwicklung.
  DATA language LIKE nast-spras.
  DATA shipment_number LIKE vttk-tknum.
  CLEAR cf_retcode.
* get data
  language = nast-spras.
  shipment_number = nast-objky.
  CALL FUNCTION 'RV_SHIPMENT_PRINT_VIEW'
       EXPORTING
            shipment_number     = shipment_number
            option_tvtk         = 'X'  "Shipmenttype J/N
            option_ttds         = 'X'  "Disposition J/N
            language            = language
            option_items        = 'X'  "Transport Items J/N
            option_segments     = 'X'  "Transport Segments J/N
            option_partners     = 'X'  "Partners J/N
            option_sales_orders = 'X'  "Sales orders J/N
            option_export_data  = 'X'  "Export data J/N
            option_packages     = 'X'  "Packages J/N
            option_flow         = ' '  "Flow J/N
            option_no_refresh   = ' '  "Refresh Tables J/N
       IMPORTING
            f_vttkvb            = vttkvb  "Shipment Header
            f_tvtk              = tvtk  "Shipmenttype
            f_tvtkt             = tvtkt  "Description Shipmenttype
            f_ttds              = ttds  "Disposition
            f_ttdst             = ttdst  "Description Disposition
            f_vbpla             = vbpla  "Packages
       TABLES
            f_vttp              = xvttp  "Shipment Items
            f_trlk              = slk  "Delivery
            f_trlp              = slp  "Delivery Item
            f_vtts              = xvtts  "Shipment Segments
            f_vtsp              = xvtsp  "Segments/Items
            f_vbpa              = xvbpa  "Partner
            f_vbadr             = xvbadr  "Address
            f_vtfa              = xvtfa  "Flow
            f_vbplk             = xvbplk  "Shipment Unit Header
            f_vbplp             = xvbplp  "Shipment Unit
            f_vbpls             = xvbpls  "Shipment Unit Sum
       EXCEPTIONS
            not_found           = 1.
  cs_header-tknum      = nast-objky.
  cs_header-schiffname = vttkvb-exti1.
  cs_header-abfahrt    = vttkvb-dptbg.
  cs_header-contnr     = vttkvb-exti2.
  cs_header-normt      = vttkvb-add01.
  cs_header-siegel     = vttkvb-signi.
  cs_header-gewbr      = vttkvb-text2.
  cs_header-gewnt      = vttkvb-text3.
  cs_header-dalen      = vttkvb-dalen.
  cs_header-dptbg      = vttkvb-dptbg.
  cs_header-add03      = vttkvb-add03.
  lc_va_tplst          = vttkvb-tplst.
  lc_va_vsart = vttkvb-vsart.
  SELECT vbeln
    FROM vttp
    INTO TABLE lc_tb_vbeln
   WHERE tknum = lc_va_tknum.
  LOOP AT lc_tb_vbeln INTO lc_wa_vbeln.
    SELECT SINGLE kunnr lifex
      FROM likp
      INTO (lc_va_kunnr, cs_header-mbcnr)
     WHERE vbeln = lc_wa_vbeln-vbeln.
    SELECT *
      FROM lips
      INTO TABLE lc_tb_lips
     WHERE vbeln = lc_wa_vbeln-vbeln.
  ENDLOOP.
  LOOP AT lc_tb_lips INTO lc_wa_lips.
    SELECT SINGLE pvvkz
      FROM /Z2a/ldm_kun
      INTO lc_va_pvvkz
     WHERE kunnr = lc_va_kunnr.
    IF lc_va_pvvkz NE 'X'.
      cf_retcode = 4.
      EXIT.
    ELSE.
      SELECT SINGLE exnum segal
       FROM eikp
       INTO (lc_va_exnum, lc_va_flag_zoll)
      WHERE refnr = lc_wa_lips-vbeln.
      SELECT SINGLE exprf
        FROM eipo
        INTO lc_va_exprf
       WHERE exnum = lc_va_exnum
         AND expos = lc_wa_lips-posnr.
      lc_va_keyseg = lc_va_exprf.
      CALL FUNCTION '/ZTR/P000_MCDATA_FROM_'
           EXPORTING
                cv_va_keytyp = '/Z2a/KEY_CU_PVABWICKLUNG'
                cv_va_keyseg = lc_va_keyseg
           TABLES
                cr_tb_bwdat  = lc_tb_bwdat.
      IF NOT lc_tb_bwdat[] IS INITIAL.
        LOOP AT lc_tb_bwdat INTO lc_wa_bwdat.
          lc_wa_bwm_result = lc_wa_bwdat-datseg.
          IF lc_wa_bwm_result-pv_relevant = 'X'.
* Kumulieren
            lc_wa_cond-matnr = lc_wa_lips-matnr.
            SELECT SINGLE maktx
              FROM makt
              INTO lc_wa_cond-arktx
             WHERE matnr = lc_wa_lips-matnr
               AND spras = 'DE'.
            lc_wa_cond-menge = lc_wa_lips-lfimg.
            lc_wa_cond-me    = lc_wa_lips-meins.
            COLLECT lc_wa_cond INTO lc_tb_cond.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDIF.
  ENDLOOP.
  cs_header-kunnr = lc_va_kunnr.
  SELECT SINGLE name1 name2 land1
    INTO (cs_header-name1,
          cs_header-name2,
          lc_va_land1)
     FROM kna1
    WHERE kunnr = lc_va_kunnr.
  SELECT SINGLE landx
    INTO cs_header-land
    FROM t005t
   WHERE spras = sy-langu
     AND land1 = lc_va_land1.
* Sortieren Aufsteigend nach Materialnr
  SORT lc_tb_cond ASCENDING BY matnr.
* Übergabe an Ausgabetabelle
  LOOP AT lc_tb_cond INTO lc_wa_cond.
    MOVE-CORRESPONDING lc_wa_cond TO lc_wa_daten.
    APPEND lc_wa_daten TO lc_tb_daten.
  ENDLOOP.
ENDFORM.                    " get_data_spat
FORM set_print_data_to_read
         USING    if_formname LIKE tnapr-sform
         CHANGING cs_print_data_to_read TYPE ledlv_print_data_to_read
                  cf_retcode.
  FIELD-SYMBOLS: <fs_print_data_to_read> TYPE xfeld.
  DATA: lt_fieldlist TYPE tsffields.
  DATA: ls_fieldlist TYPE LINE OF tsffields.
  DATA: lf_field1 TYPE LINE OF tsffields.
  DATA: lf_field2 TYPE LINE OF tsffields.
  DATA: lf_field3 TYPE LINE OF tsffields.
  CALL FUNCTION 'SSF_FIELD_LIST'
    EXPORTING
      formname                = if_formname
*     VARIANT                 = ' '
    IMPORTING
      fieldlist               = lt_fieldlist
   EXCEPTIONS
     no_form                  = 1
     no_function_module       = 2
     OTHERS                   = 3.
  IF sy-subrc <> 0.
    cf_retcode = sy-subrc.
    CLEAR lt_fieldlist.
  ELSE.
* set print data requirements
    LOOP AT lt_fieldlist INTO ls_fieldlist.
      SPLIT ls_fieldlist AT '-' INTO lf_field1 lf_field2 lf_field3.
* <<<< START_OF_INSERTION_HP_350342 >>>>
      IF lf_field1 = 'IS_DLV_DELNOTE' AND lf_field2 = 'IT_SERNR'.
        lf_field2 = 'IT_SERNO'.
      ENDIF.
* <<<< END_OF_INSERTION_HP_350342 >>>>
      ASSIGN COMPONENT lf_field2 OF STRUCTURE
                       cs_print_data_to_read TO <fs_print_data_to_read>.
      IF sy-subrc = 0.
        <fs_print_data_to_read> = 'X'.
      ENDIF.
    ENDLOOP.
* header data is always required
    cs_print_data_to_read-hd_gen = 'X'.
* adress is always required for print param
    cs_print_data_to_read-hd_adr = 'X'.
* organisational data is always required for include texts
    cs_print_data_to_read-hd_org = 'X'.
  ENDIF.
ENDFORM.                    " set_print_data_to_read
*&      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_CF_RETCODE  text
FORM set_print_param USING    is_addr_key LIKE addr_key
*                              lc_va_tknum
                              lc_va_lfnr TYPE nrlevel
                     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.
  DATA: lc_va_suffix TYPE rspo2name.
  lf_repid = sy-repid.
  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.
  SHIFT lc_va_lfnr LEFT DELETING LEADING '0'.
  CONCATENATE 'PV' lc_va_lfnr INTO lc_va_suffix.
  IF cf_retcode = 0.
    MOVE-CORRESPONDING ls_itcpo TO cs_composer_param.
    cs_composer_param-tdsuffix2   = lc_va_suffix.
    cs_control_param-device      = lf_device.
    cs_control_param-no_dialog   = 'X'.
    cs_control_param-preview     = screen.
    cs_control_param-getotf      = ls_itcpo-tdgetotf.
    cs_control_param-langu       = nast-spras.
  ENDIF.
ENDFORM.                    " set_print_param
FORM protocol_nast_update.
  CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
       EXPORTING
            msg_arbgb = '/Z2a/PVSCHEIN'
            msg_nr    = '001'
            msg_ty    = 'E'
*              MSG_V2    = SYST-MSGV2
*              MSG_V3    = SYST-MSGV3
*              MSG_V4    = SYST-MSGV4
*              MSG_V1    = SYST-MSGV1
       EXCEPTIONS
            OTHERS    = 1.
ENDFORM.                   

Hello!
I have to customize the enclosed source code so it does the following:
print out for each shipment (see FuBa:RV_SHIPMENT_PRINT_VIEW
parameter slp) really seperated by for every shipment item LIKP-VBELN
and not for the whole VTTP-TKNUM.
The parameter "slp" must be stripted so by leaving
of the routine "get_data_pv" has only the datas of the current
LIKP-VBELN, and in the next step taking the next LIKP-VBELN
and so on. Right now it performs only one time for one  VTTP-TKNUM.
If you don't understand VTTP-TKNUM and LIKP-VBELN please refer
to Transaction SE11.
Reagrds
Ilhan

Similar Messages

  • PO print out of delivery schedule

    Hi,
    Suppose I am generating a PO , in some cases I will be giving delivery schedule for some items in item details.
    I want this to come in the print out.
    But its not coming .
    Please advise.
    regards,

    Hi
    You can include logic with the help of Developre, If information is there in EKET for Purchase order ask him to include in print.
    regards
    Srinivas

  • PO print outs having delivery address as of storage location

    Hello Experts,
    What setting need to be done to have storage location address as delivery address in PO by default.

    In your print program pass values plant and storage location in table TWLAD and in that table you will get address number .Use this address number in ADRC table and get address details in PO output form.
    Please explain above logic to your technical team and they will do program changes.

  • Print out the delivery schedule item wise

    Hi friends..
    can any one pl tell me how to take the printout of the delivery schedules item wise.
    i have checked the ME80RN but it doesnt work for me.
    client want to print delivery schedule not SCHEDULING AGGREMENT.
    Your help will be highly appreciated..with points..
    Regards,
    Anil

    Hi,
    Hope you can create an access sequence with material as a field and create a condition record based on this...
    Bcoz mess determination takes place at header level.
    Reg,
    Deepak

  • Print out all contacts with all info showing in Outlook 2013

    In Outlook 2013, if you click the Contacts group you want to print, then go to File...Print, the only option is to essentially print the view you have when clicking into the People menu.
    How can I print out every contact showing all the info in each contact?

    Hi,
    Do you want to print each contact into each printout page with all the info? If so, you can try printing using the
    Memo Style. To do this, click the contact group you want to print, select one contact and then press Ctrl + A to select all contacts in the contact group. Then, click File > Print. Under
    Settings in the Print tab, select Memo Style. Click
    Print.
    For more information about print contacts in Outlook 2013, please refer:
    http://office.microsoft.com/en-us/outlook-help/print-your-contacts-HA102749446.aspx
    Regards,
    Steve Fan
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please click
    here

  • Delivery schedule print out and number

    Dear Expert
    Our client need to implement the scheduling agreement in the company , but the requirement as follows their are two dept one is for vendor dealing and our is meant for requirement generation , so scheduling agreement is generated by one dept and delivery schedule will be generated by other , is it possible to  generate different for delivery schedule?/it not how can we configure the system as such when we release the delivery schedule on the basis of FRC release procedure then only print out should be generated for the deliverry schedule and print out should only consider those line item of delivery schedule which are release no other , i.e if for e.g for 1st month the delivery schedule is generated against the PR 's for different line item of Scheduling agreement , then only  those item wil be consider which are release as per the FRC , then for the next delivery schedule only those item to be consider in the print out which are release 2nd time. how can we map this scenario in the system
    Regards
    farhan

    Dear Expert
    can we customize system as such that we cannot  maintained delivery schedule before the  release of the  SA
    Regards
    farhan

  • In po,every time i want to add the message for print out.

    in po,every time i want to add the message for print out.
    is there any permanent solution for above issues ?

    Hi,
    1) use transaction nace
    2)Select application EF  and go to condition records
    3) o/p type is neu , select the same and double click on it .
    4) select paricular condition table.
    5) maintain condition records , means for particular combination NEU should appear automatically in PO print.

  • Print Preview of Out bound delivery is not available in VL71

    Hi Experts,
                 I have created Outbound delivery with VL10B (against Purchase Order) and also set up output parameter in VL02N (Extra->elivery output -> Header)
                 Now I want to take Print out of this Outbound delivey in VL71 , I cant even see the Print preview.  I have already maintained Output type , Access sequence and condition table in SPRO . I have also maintained condition record also (with delivery type and Shipping point).
                  Any help on this

    Check if output triggered successfully in delivery.
    If yes, then please use indicator "Processing Mode" appropiately on the main selection screen of VL71.
    If not, please see the error and try to resolve it.
    Also check from main screen of VL02n where you enter delivery no, don't go inside the delivery screen, from main screen itself,
    Outbound delivery> Issue Delivery output
    Hope it helps
    Regards
    Anand Misra

  • Sapscript - print out seperate labels for multiple delivery items

    Hello,
    we do have an output type that prints barcode labels for deliveries (VL02n).
    Now if there are more than one delivery item on the delivery, it will only print out a label for the first item.
    How can I trigger that all items will be printed out on a seperate label each?
    thanks
    Anne

    Hi,
    Just open the script which prints the lables and check for the variable name used for label printing
    Check the script for variables and pass the value to that avriables and those to be declred in your print/driver program.
    when you call write_from in the loop  there you give a window name what ever the value in the variable it will pass to script
    Regards
    Krishna

  • Print all delivery number on invoice print out

    Hi ,
    When we create a  invoice against two delivery only one first delivery number shown on invoice ?
    but my client want to print all delivery number on invoice print out.
    can you please guide me how to provide it coz only one delivery print .
    Regards,
    Aditya

    Hi Adhithya,
    Ask your Developer to add all the Deliverys under the billing form need to print in the billing
    give him the logic VBRK-vblen go toVBFA pass the VBLEN pick all deliverys display in the billing form.
    which need to add in the out put type.
    Thanks...

  • TS4118 When I print out my ical calendars, there are three duplicate events happening every day of the week and I never entered this event?

    When I print out my calendars from ical, there is one event that is reoccurring 3x/day/every day of week! It is not showing on the actual calendar and I cannot figure out how or where it's coming from? It's in the calendar marked Jimmys action which just shows my sons activities and for this activitiy, I put one day with a recurring weekly on just two days of the week at a specific time and this is showing up as well and correctly? What should I do to remedy this?

    UPDATE: I think I found the answer to my problem. I travel between two time zones and recently started listing event times as "floating" so they don't get messed up when I travel between west and east coasts. It seems that when I want to print out a calendar sheet, the time of the event doesn't show up if it's a "floating" event. So, I need to go back to putting a time zone in and turning off "time support" in Preferences for iCal. BTW this (in reverse) is a solution for those who don't want to see appointment times printed out – make it a "floating" event.

  • Every document I print also prints out a summary sheet at the end.  I want to disable this function

    Every document I print also prints out a summary sheet at the end.  i want to turn off this function.

    Check the print options in the dialog box.  If you don't have all this information displayed, click the circled arrow next to the printer name.  Click the program option drop down, it's the one with a horizontal line to the left and right, check the cover page option.  I can be set to before or after a print job.  Just say none.
    Regards,
    Captfred

  • How to use Applescript to print out a certain calendar at 7am every morning?

    Hey guys,
    I am trying to use AppleScript to print out one of my calendars each day at 7am every morning.
    I have come up with this so far:
    tell application "Calendar"
           view calendar "My Appointments" at (my (current date))
           switch view to day view
           activate
                        tell application "System Events"
                     keystroke "p" using command down
                     delay 1 -- (seconds)
                     tell process "Calendar"
                                                      tell window "Print"
                                                                     if value of checkbox "Calendar Keys" is not 0 then
                                      click checkbox "Calendar Keys"
                               end if
                                                      end tell
                                       end tell
                        end tell
    end tell
    The problem with this is that it will print out whatever calendars are currently viewable. I can't figure out how to tell it to deselect other calendars and just select the one I want. I also want to tell it to print this out at 7am every morning.
    Any help would be very appreciated!

    If you wanted to do the printout over multiple days, you would be best to loop through each day's events in the way the current script does, but to put a new loop around it that gets each new day's data:
    --opens a temporary file
    set fileRef to open for access ((path to desktop) as string) & "meetings.txt" with write permission
    --effectively empties the file
    set eof fileRef to 0
    tell application "Calendar"
              set dayCount to 9 --this will be the number of days to look forward (not including today)
              repeat with currentDay from 0 to dayCount
                        set startList to {}
      --get's today's date
      --set startRange to ((current date) + 12 * days) -- I used this for testing, to point to a day that had many appointments.  I've left it so you can use it, too.
                        set startRange to ((current date) + (currentDay * days))
      --set the start of the range to previous midnight
                        set hours of startRange to 0
                        set minutes of startRange to 0
                        set seconds of startRange to 0
      --set end of the range to next midnight
                        set endRange to (startRange + 1 * days)
      --get today's events
                        set todaysEvents to get (events of calendar "My Appointments" whose (start date is greater than startRange) and (end date is less than endRange))
      --make a new list with start time of the event for sort purposes
                        repeat with theEvent in todaysEvents
                                  set end of startList to {startdate:start date of theEvent, eventID:theEvent}
                        end repeat
      --sort using a bubble sort (suitable for short lists)
                        repeat with i from 1 to (count of startList) - 1
                                  repeat with j from i + 1 to count of startList
                                            if startdate of item j of startList < startdate of item i of startList then
                                                      set temp to item i of startList
                                                      set item i of startList to item j of startList
                                                      set item j of startList to temp
                                            end if
                                  end repeat
                        end repeat
      --empty the original list
                        set todaysEvents to {}
      --repopulate the list in correct chronological order
                        repeat with theEvent in startList
                                  set end of todaysEvents to eventID of theEvent
                        end repeat
      --write today's date to the file
      write (date string of startRange & return & return) to fileRef
      --if there are no events, write this to the file as well
                        if length of todaysEvents is 0 then
                                  write "No events" & return & return to fileRef
                        else
      --process each event into format: hh:mm-hh:mm/new line/event summary
                                  repeat with theEvent in todaysEvents
                                            set startdate to start date of theEvent
                                            set enddate to end date of theEvent
                                            set startHours to hours of startdate as string
                                            if length of startHours is 1 then set startHours to "0" & startHours
                                            set startMins to minutes of startdate as string
                                            if length of startMins is 1 then set startMins to "0" & startMins
                                            set starttime to startHours & ":" & startMins
                                            set endHours to hours of enddate as string
                                            if length of endHours is 1 then set endHours to "0" & endHours
                                            set endMins to minutes of enddate as string
                                            if length of endMins is 1 then set endMins to "0" & endMins
                                            set endTime to endHours & ":" & endMins
      --write the event to the file
                                            set theSummary to (starttime & "-" & endTime & return & summary of theEvent & return & return) as string
      write theSummary to fileRef
                                  end repeat
                        end if
      write return to fileRef
              end repeat
    end tell
    --close the file
    close access fileRef
    --print the file
    set theFile to (((path to desktop) as text) & "meetings.txt") as alias
    tell application "TextEdit"
              print theFile without print dialog
    end tell

  • How to avoid that every page of a smartform is going to be printed out

    Hi,
    I have following problem. In my smartform I builded different pages (like a cover page, different lists etc.). The user should decide by setting parameters what lists he want to print. So if he don´t need the cover page, it should not be printed out.
    Is there any way to set this up in the smartform? Right now, the printing parameters (what the user wants to print) are stored in an internal table and should be processed in the smartform. My problem is that there is no way to implement conditions on a page in a smartform.
    Please let me know if somebody has a solution for this requirement.
    Thanks a lot,
    John Caspar
    <MOVED TO CORRECT FORUM BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Apr 15, 2009 8:49 AM

    Hi Micky,
    The external debugging works. Thank you very much!
    And how can I reward you?

  • Today I received an email from USPS saying a courier attempted to make a delivery and I should print out this label. As soon as I tried to do this I knew this was suspicious. I immediately sent the email to a spam abuse ctr and deleted it. what else to do

    I opened an email from USPS and when I did it stated that a courier had attempted to deliver a parcel and that I should print out the label and bring to loca PO to claim pkge. Yeah, I fell for it, and it was only after I clicked on print that I realized it was spam. I did report it to a spam abuse cte and deleted it but becasue I opned it and clicked the print, now I'm worried. I have a MacBook Air. Should I do anything else to protect myself?

    As long as you didn't give any information, there may not be any problem from this.
    http://support.apple.com/kb/ht4933
    Best.

Maybe you are looking for

  • Condition type is missing in Pricing Procedure determination

    Hi experts, We have a problem with Pricing Condition type in CRM. We have created a Transction in CRM as a follow up for the Transaction which is replicated from ECC to CRM the pricing procedure has been determined. But the net value is "0". when I c

  • How can I restore my Mac Book Pro?

    Hi, I want to restore my MacBook Pro that is running Mac OS X Lion (Version 10.7.5) It's running very slow and I want to completely restore everything like I had just bought it.. I don't have any install discs or anything. I found a youtube video tha

  • Working with DIAdem REPORT in DIAdem SCRIPT

    Hello, I am working with DIAdem 9.1 Advanced. I would like to create a report with a 2D graph object containing one curve (X,Y1) or (X,Y2). The user has to choose between (X,Y1) and (X,Y2) via a dialog box. I want to generate this report with a VBS s

  • Camera Raw 4.6 and Elements 6.0

    Installed Camera Raw 4.6 into Elements 6.0 & 5.0, but Elements 6.0 will not recognize Sigma Dp1 X3F files, but 5.0 will. The DNG converter works. Any clues to what could be going on Jack

  • Web service deployment problem under sun 8

    I am deploying web service under sun8 app server. When I use wscompile to generate wsdl file it puts the following for the the service location: <soap:address location="REPLACE_WITH_ACTUAL_URL"/> which is replaced on deployment by the actual server n