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

SOLVED: Printing label from user-exit MWMTO002

Development SAPscript/ Smartforms

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

SOLVED: Printing label from user-exit MWMTO002

Postby roortman » Tue Sep 14, 2010 7:30 am

Hi all,

I have a problem. We need to print a label AFTER Transfer order confirmation. Only user-exit possible to do this is MWMTO002.
See code below.

Code: Select all
*----------------------------------------------------------------------*
*   INCLUDE ZXLTOU02                                                   *
*----------------------------------------------------------------------*
*"*"Globale Schnittstelle:
*"       IMPORTING
*"              I_LTAK_VB LIKE  LTAK_VB STRUCTURE  LTAK_VB
*"       TABLES
*"              T_LTAP_VB STRUCTURE  LTAP_VB
*----------------------------------------------------------------------*
* User-Exit to print the label on the picking container                *
* Developer:  R. Oortman                                               *
* Date:       14-09-2010                                               *
*----------------------------------------------------------------------*
break logifact.
IF i_ltak_vb-lgnum EQ '199'.

  TYPES:  BEGIN OF ty_data,
            lgnum TYPE ltak-lgnum,
            tanum TYPE ltak-tanum,
            refnr TYPE ltak-refnr,
            berot1 TYPE likp-berot,
            berot2 TYPE likp-berot,
            berot3 TYPE likp-berot,
            berot4 TYPE likp-berot,
            berot5 TYPE likp-berot,
            berot6 TYPE likp-berot,
            berot7 TYPE likp-berot,
            vtext TYPE vbsk-vtext,
            lines TYPE char20,
          END OF ty_data.

  DATA: wa_data TYPE ty_data,
        gv_old_berot TYPE likp-berot,
        it_likp TYPE TABLE OF likp,
        it_likp2 TYPE TABLE OF likp,
        wa_likp TYPE likp,
        it_vbss TYPE TABLE OF vbss,
        lv_lines TYPE i.

  wa_data-lgnum = i_ltak_vb-lgnum.
  wa_data-tanum = i_ltak_vb-tanum.
  wa_data-refnr = i_ltak_vb-refnr.

* Get pick wave description.
  SELECT SINGLE vtext INTO wa_data-vtext
                      FROM vbsk
                      WHERE sammg EQ wa_data-refnr.
* Get all the deliveries in the group.
  SELECT * FROM vbss INTO TABLE it_vbss WHERE sammg EQ wa_data-refnr.
* Get the delivery data for the whole group.
  SELECT * FROM likp INTO TABLE it_likp FOR ALL ENTRIES IN it_vbss
                                WHERE vbeln EQ it_vbss-vbeln.
* Backup IT_LIKP to use the IT_LIKP2 for calculation of the number of
* packaging mats.
  it_likp2[] = it_likp[].

* Determine if group is singleline, multiline or mixed group.
  SORT it_likp BY lprio.
  DELETE ADJACENT DUPLICATES FROM it_likp COMPARING lprio.
  DESCRIBE TABLE it_likp LINES lv_lines.

  IF lv_lines EQ '1'.
    READ TABLE it_likp INTO wa_likp INDEX 1.
    IF wa_likp-lprio EQ '51' OR wa_likp-lprio EQ '53'.
      wa_data-lines = 'SINGLELINE'.
    ELSEIF wa_likp-lprio EQ '52'.
      wa_data-lines = 'MULTILINE'.
    ENDIF.
  ELSE.
    wa_data-lines = 'MIXED'.
  ENDIF.

* Get number of packaging mats.
  SORT it_likp2 BY berot.
  DELETE ADJACENT DUPLICATES FROM it_likp2 COMPARING berot.
  DESCRIBE TABLE it_likp2 LINES lv_lines.

  LOOP AT it_likp2 INTO wa_likp.
    CASE sy-tabix.
      WHEN '1'.
        wa_data-berot1 = wa_likp-berot.
      WHEN '2'.
        wa_data-berot2 = wa_likp-berot.
      WHEN '3'.
        wa_data-berot3 = wa_likp-berot.
      WHEN '4'.
        wa_data-berot4 = wa_likp-berot.
      WHEN '5'.
        wa_data-berot5 = wa_likp-berot.
      WHEN '6'.
        wa_data-berot6 = wa_likp-berot.
      WHEN '7'.
        wa_data-berot7 = wa_likp-berot.
      WHEN OTHERS.
        wa_data-berot7 = 'MEER DAN 7 SOORTEN VERPAKKINGSMIDDELEN'.
    ENDCASE.
  ENDLOOP.

* Set Output parameters
  DATA: wa_itcpo TYPE itcpo,
        edrucker TYPE rldru-ldest.

  wa_itcpo-tddest     = edrucker.
  wa_itcpo-tdsuffix1  = 'CARR'.
  wa_itcpo-tdimmed    = 'X'.
  wa_itcpo-tdcopies   = 1.
  wa_itcpo-tdprogram  = sy-repid.
  wa_itcpo-tddataset  = 'TOLABL'.
  wa_itcpo-tddelete   = ' '.
  wa_itcpo-tdtitle    = ' label'.
  wa_itcpo-tdcovtitle = 'Carrier label'.

* Open form
  CALL FUNCTION 'OPEN_FORM'
       EXPORTING
            dialog                      = ' '
            form                        = 'ZWM_LBL_ROLCO'
            options                     = wa_itcpo
       EXCEPTIONS
            canceled                    = 1
            device                      = 2
            form                        = 3
            options                     = 4
            unclosed                    = 5
            mail_options                = 6
            archive_error               = 7
            invalid_fax_number          = 8
            more_params_needed_in_batch = 9
            spool_error                 = 10
            OTHERS                      = 11.

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

  CALL FUNCTION 'WRITE_FORM'
       EXPORTING
            element                  = 'MAIN'
       EXCEPTIONS
            element                  = 1
            function                 = 2
            type                     = 3
            unopened                 = 4
            unstarted                = 5
            window                   = 6
            bad_pageformat_for_print = 7
            spool_error              = 8
            OTHERS                   = 9.

  IF sy-subrc <> 0.
  ENDIF.

  CALL FUNCTION 'CLOSE_FORM'
       EXCEPTIONS
            unopened                 = 1
            bad_pageformat_for_print = 2
            send_error               = 3
            spool_error              = 4
            OTHERS                   = 5.

  IF sy-subrc <> 0.
  ENDIF.
ENDIF.



The label excists ofcourse. My 'WA_DATA' structure is filled nicely but when the label is printed I have no data on the label.
See SAPScript below:
Code: Select all
/E   MAIN                                                                                           
/    ^XA                                                                                             
/    ^LT0^MNN^MTD^PON^PMN^LH0,0^JMA^PR2,2^MD10^^MMT                                                 
/    ^LL1199                                                                                         
/    ^PW799                                                                                         
/    ^LS0                                                                                           
/    ^BY6,2.5,160^FT241,1155^B3B,N,,Y,N^FD&WA_DATA-TANUM&^FS                                         
/    ^FT329,751^A0B,34,33^FH\^FD&WA_DATA-VTEXT&^FS                                                   
/    ^FT765,748^A0B,45,45^FH\^FD&WA_DATA-LINES&^FS                                                   
/    ^FT435,749^A0B,34,33^FH\^FD&WA_DATA-BEROT1&^FS                                                 
/    ^FT483,749^A0B,34,33^FH\^FD&WA_DATA-BEROT2&^FS                                                 
/    ^FT532,749^A0B,34,33^FH\^FD&WA_DATA-BEROT3&^FS                                                 
/    ^FT579,746^A0B,34,33^FH\^FD&WA_DATA-BEROT4&^FS                                                 
/    ^FT626,746^A0B,34,33^FH\^FD&WA_DATA-BEROT5&^FS                                                 
/    ^FT666,746^A0B,34,33^FH\^FD&WA_DATA-BEROT6&^FS                                                 
/    ^FT706,746^A0B,34,33^FH\^FD&WA_DATA-BEROT7&^FS                                                 
/    ^FT55,1151^A0B,34,33^FH\^FDTransportopdracht:^FS                                               
/    ^FT328,1152^A0B,34,33^FH\^FDOmschrijving pickgroep^FS                                           
/    ^FT387,1150^A0B,34,33^FH\^FDBetrokken verpakkingsmiddelen:^FS                                   
/    ^FT759,1151^A0B,34,33^FH\^FDMulti -of Singleline^FS                                             
/    ^XZ


Can any1 help me out with this with a reason why this might be happening?

Kind regards,

Robbert
Last edited by roortman on Tue Sep 14, 2010 8:25 am, edited 2 times in total.
roortman
 
Posts: 221
Joined: Wed Sep 13, 2006 4:14 am

Re: Printing label from user-exit MWMTO002

Postby SHS » Tue Sep 14, 2010 8:09 am

I think you should declare your wa_data structure on a global level, not within the userexit.

Try to declare wa_data in include ZXLTOTOP (which is part of the userexit function group) and try again.
Don't forget to explicitly clear wa_data in your userexit in this case.

Good luck
SHS
 
Posts: 483
Joined: Mon Mar 06, 2006 3:57 am

SOLVED: Printing label from user-exit MWMTO002

Postby roortman » Tue Sep 14, 2010 8:16 am

I was just about to type your reply :-)
I saved the post and suddenly remembered it.

I'm an moron :-)
roortman
 
Posts: 221
Joined: Wed Sep 13, 2006 4:14 am


Return to SAPscript/Smartforms

Who is online

Users browsing this forum: No registered users and 2 guests





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