This website is not affiliated with, sponsored by, or approved by SAP AG.

Program for Printing MIGO Labels doing things on its own

Development SAPscript/ Smartforms

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

Program for Printing MIGO Labels doing things on its own

Postby Sapslzr » Mon Nov 29, 2010 9:14 am

I am not an ABAPER and I am using the following code to print labels for receiving materials in MIGO. My problem its that althought in NACE all the parameters are there, there is a couple of things this code seems to be doing on its own:

    1. On the first item line in MIGO always executes a message (WE04) even if it not set up in NACE.

    2. When it founds a message to print not only does it for that line but does it for all the item lines on MIGO, so if I want to receive 2 items, I end up with 4 labels (2 for each)

If somebody knows where can I check those errors. First it goes to this program:

Code: Select all
*&---------------------------------------------------------------------*
*& Report  ZIMPRIMEETIQ
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT  zimprimeetiq.
*INCLUDE ZMILLS_MM_OC_TOP.
tables: nast,                          "Messages
        *nast,                         "Messages
        tnapr,                         "Programs & Forms
        itcpo,                         "Communicationarea for Spool
        arc_params,                    "Archive parameters
        toa_dara,                      "Archive parameters
        addr_key,
        mara.                      "Adressnumber for ADDRESS

DATA: xscreen.

INCLUDE ZMILLS_MM_OC_ETI.


And in ZMILLS_MM_OC_ETI:

Code: Select all
*&---------------------------------------------------------------------*
*&  Include           ZMILLS_MM_OC_ETI
*&---------------------------------------------------------------------*
FORM entry USING ent_retco ent_screen.
  DATA: l_druvo LIKE t166k-druvo,
        l_nast  LIKE nast,
        l_from_memory.

*       l_doc   TYPE meein_purchase_doc_print.
  DATA: ls_print_data_to_read TYPE lbbil_print_data_to_read.
  DATA: ls_bil_invoice TYPE lbbil_invoice.
  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: w_charg TYPE  charg_d,
      w_matnr TYPE  matnr,
      w_menge TYPE  menge_d,
      w_lifnr TYPE  elifn,
      w_meins TYPE  meins,
      w_licha TYPE  lichn.

DATA: BEGIN OF t_mseg OCCURS 0,
      charg LIKE mseg-charg,
      matnr LIKE mseg-matnr,
      menge LIKE mseg-menge,
      lifnr LIKE mseg-lifnr,
      meins LIKE mseg-meins,
      licha LIKE mch1-licha,
END OF t_mseg.



  xscreen = ent_screen.

  CLEAR ent_retco.
  IF nast-aende EQ space.
    l_druvo = '1'.
  ELSE.
    l_druvo = '2'.
  ENDIF.

*  CALL FUNCTION 'ME_READ_PO_FOR_PRINTING'
*       EXPORTING
*            ix_nast        = nast
*            ix_screen      = ent_screen
*       IMPORTING
*            ex_retco       = ent_retco
*            ex_nast        = l_nast
**            doc            = l_doc
*       CHANGING
*            cx_druvo       = l_druvo
*            cx_from_memory = l_from_memory.
*  CHECK ent_retco EQ 0.
*  IF nast-adrnr IS INITIAL.
**   PERFORM get_addr_key
**                         CHANGING ls_addr_key.
*  ELSE.
*    ls_addr_key = nast-adrnr.
*  ENDIF.

* Fill up pricing condition table if calling from ME9F
*  IF l_doc-xtkomv IS INITIAL.
*    SELECT * INTO TABLE l_doc-xtkomv FROM konv
*                                     WHERE knumv = l_doc-xekko-knumv.
*  ENDIF.

*Obtiene datos
  SELECT *
  INTO CORRESPONDING FIELDS OF TABLE  t_mseg
  FROM mseg
  WHERE mblnr = nast-objky(10)
    AND mjahr = nast-objky+10(4).



**Set the print Parameters
  PERFORM set_print_param USING     ls_addr_key
                          CHANGING  ls_control_param
                                    ls_composer_param
                                    ls_recipient
                                    ls_sender
                                    ent_retco.

*Get the Smart Form name.
*<-- CS 27/11/2010
*  IF NOT tnapr-sform IS INITIAL.
*--> CS 27/11/2010

    lf_formname = tnapr-sform.

*<-- CS 27/11/2010
*  ELSE.
*    lf_formname = tnapr-fonam.
*  ENDIF.
*--> CS 27/11/2010

* Determine smartform function module for invoice
  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.
*  error handling
*    ent_retco = sy-subrc.
*    PERFORM protocol_update_i.
  ENDIF.


  LOOP AT t_mseg.

*<-- CS 27/11/2010
*    IF NOT t_mseg-charg IS INITIAL.
*--> CS 27/11/2010

      SELECT SINGLE licha
      INTO w_licha
      FROM mch1
      WHERE charg = t_mseg-charg
        AND matnr = t_mseg-matnr.

*<-- CS 27/11/2010
*    ENDIF.
*--> CS 27/11/2010

    w_charg = t_mseg-charg.
    w_matnr = t_mseg-matnr.
    w_menge = t_mseg-menge.
    w_lifnr = t_mseg-lifnr.
    w_meins = t_mseg-meins.


  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 = ' '
            i_charg = w_charg
            i_matnr = w_matnr
            i_menge = w_menge
            i_lifnr = w_lifnr
            i_meins = w_meins
            i_licha = w_licha
*       TABLES
*            l_xekpo            = l_doc-xekpo[]
*            l_xekpa            = l_doc-xekpa[]
*            l_xpekpo           = l_doc-xpekpo[]
*            l_xeket            = l_doc-xeket[]
*            l_xtkomv           = l_doc-xtkomv[]
*            l_xekkn            = l_doc-xekkn[]
*            l_xekek            = l_doc-xekek[]
*            l_xkomk            = l_xkomk
*       EXCEPTIONS
            formatting_error   = 1
            internal_error     = 2
            send_error         = 3
            user_canceled      = 4
            OTHERS             = 5.


  endloop.


  IF sy-subrc <> 0.
*    ent_retco = sy-subrc.
*    PERFORM protocol_update_i.

* get SmartForm protocoll and store it in the NAST protocoll
*    PERFORM add_smfrm_prot.
  ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*&      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
                     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.

  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_composer_param-tdnoprint = 'X'.                     "Note 591576
    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.
  ENDIF.


Thanks
Meditate Everyday
Sapslzr
 
Posts: 119
Joined: Sat Oct 24, 2009 11:43 am

Re: Program for Printing MIGO Labels doing things on its own

Postby Gothmog » Tue Nov 30, 2010 4:19 am

Your printing program indeed selects all items in the material document:
Code: Select all
  SELECT *
  INTO CORRESPONDING FIELDS OF TABLE  t_mseg
  FROM mseg
  WHERE mblnr = nast-objky(10)
    AND mjahr = nast-objky+10(4).
and then prints a label for each :
Code: Select all
LOOP AT t_mseg.

* (some data manipulation)

  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 = ' '
            i_charg = w_charg
            i_matnr = w_matnr
            i_menge = w_menge
            i_lifnr = w_lifnr
            i_meins = w_meins
            i_licha = w_licha
*       TABLES
*            l_xekpo            = l_doc-xekpo[]
*            l_xekpa            = l_doc-xekpa[]
*            l_xpekpo           = l_doc-xpekpo[]
*            l_xeket            = l_doc-xeket[]
*            l_xtkomv           = l_doc-xtkomv[]
*            l_xekkn            = l_doc-xekkn[]
*            l_xekek            = l_doc-xekek[]
*            l_xkomk            = l_xkomk
*       EXCEPTIONS
            formatting_error   = 1
            internal_error     = 2
            send_error         = 3
            user_canceled      = 4
            OTHERS             = 5.

  endloop.

So it is obviously designed as a header-level output.
How is the output triggered ? At item level ?
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1942
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: Program for Printing MIGO Labels doing things on its own

Postby Sapslzr » Tue Nov 30, 2010 9:06 am

Thank you Gothmog

The output is generated with the MIGO document, and Its by item level.

So if I dont want it to print labels for all the items and just print the message for the current line should I add another condition on the first SELECT or do I need an IF before calling the function lf_fm_name ?

Thank you again.

Regards,
Carlos
Meditate Everyday
Sapslzr
 
Posts: 119
Joined: Sat Oct 24, 2009 11:43 am

Re: Program for Printing MIGO Labels doing things on its own

Postby Gothmog » Tue Nov 30, 2010 9:23 am

You'd be better selecting just the line of mseg you seek (they table key should be in nast-objky) in a structure, and get tid of the loop.
68 74 74 70 3a 2f 2f 74 69 6e 79 75 72 6c 2e 63 6f 6d 2f 62 64 6f 37 6d 77 67
Gothmog
 
Posts: 1942
Joined: Wed Sep 12, 2007 4:46 am
Location: Probably not home

Re: Program for Printing MIGO Labels doing things on its own

Postby Sapslzr » Tue Nov 30, 2010 3:14 pm

Thanks a lot Gothmog, I will do that...
Meditate Everyday
Sapslzr
 
Posts: 119
Joined: Sat Oct 24, 2009 11:43 am


Return to SAPscript/Smartforms

Who is online

Users browsing this forum: No registered users and 5 guests





This website is not affiliated with, sponsored by, or approved by SAP AG.