Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Pass string to Printer

Former Member
0 Likes
1,508

Hi All,

Can someone advise to me whether it is possible to send a string to a printer from a SAP program? Im using a ZEBRA printer and want to send ZPL code to it in raw print format.

If so how do i go about doing it? How would i specify printer location and so on.

Many Thanks - David

1 ACCEPTED SOLUTION
Read only

brad_bohn
Active Contributor
0 Likes
1,289

I don't have any experience with ZEBRAs but since no one has answered, here's some info. You can send commands to printers using the PRINT-CONTROL command from lists or forms. Since you've already specified an output device, SAP knows where to send the control. You'll find a list of available print control commands for your device type in transaction SPAD. You can also create your own print controls and add them through SPAD. If you're using one of the form development technologies, you can also specify a page format that has printer specific commands attached to it. This is commonly used to load PCL commands for tray initialization, font loading, etc.

7 REPLIES 7
Read only

brad_bohn
Active Contributor
0 Likes
1,290

I don't have any experience with ZEBRAs but since no one has answered, here's some info. You can send commands to printers using the PRINT-CONTROL command from lists or forms. Since you've already specified an output device, SAP knows where to send the control. You'll find a list of available print control commands for your device type in transaction SPAD. You can also create your own print controls and add them through SPAD. If you're using one of the form development technologies, you can also specify a page format that has printer specific commands attached to it. This is commonly used to load PCL commands for tray initialization, font loading, etc.

Read only

Former Member
0 Likes
1,289

Hi Brad,

Thanks for you response.

I pretty much stumbled across this solution myself too. Many thanks for taking the time though.

David

Read only

Former Member
0 Likes
1,289

Brad,

Sorry to bother, i managed to pass a string to the printer using this method but its not what i was looking for as i thought the printer would then interpate the printer code string wrapper (in this case ZPL code). But instead it just prints the string that i pass through. This makes sense to be honest but i was wondering if it is possible to pass the string as raw data so that it can be interpreted.

I've seen the RDI (raw data interface) parameter within OPEN_FORM but i can't see an object to pass the string wrapper to.

Any ideas eould be greatly appreciated.

Thanks - David

Read only

Former Member
0 Likes
1,289

Foillow - up

Read only

0 Likes
1,289

Hi,

Check this code. it might help u.

loop at it_printdata into wa_final.

    check wa_final-lgort ne space .

    output_options-tddest  = pripar-pdest.
    output_options-tdimmed = pripar-primm.
    output_options-tdnewid = 'X'.
    output_options-tdcopies = wa_final-prcop.
    append output_options.

    control_parameters-preview   = ' '.
    control_parameters-no_open   = 'X'.
    control_parameters-no_close  = 'X'.
    control_parameters-no_dialog = 'X'.
    append control_parameters.


    if wa_final-type eq 'MTS'.

*     IF wa_final-vbeln EQ space AND  wa_final-kdpos IS INITIAL.
      call function 'SSF_FUNCTION_MODULE_NAME'
        exporting
          formname           = p_form1
        importing
          fm_name            = fm_name1
        exceptions
          no_form            = 1
          no_function_module = 2
          others             = 3.
      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 'SSF_OPEN'
        exporting
          user_settings      = ' '
          output_options     = output_options
          control_parameters = control_parameters.

      call function fm_name1
        exporting
          control_parameters = control_parameters
          output_options     = output_options
          v_matnr            = wa_final-matnr
          v_werks            = wa_final-swerk
          v_lgort            = wa_final-lgort
          v_sernr            = wa_final-sernr.
      if sy-subrc eq 0.
        flag = 'X'.
      endif.
      call function 'SSF_CLOSE'.

    else.

      check wa_final-vbeln ne space and not wa_final-posnr is initial .

      call function 'SSF_FUNCTION_MODULE_NAME'
        exporting
          formname           = p_form2
        importing
          fm_name            = fm_name2
        exceptions
          no_form            = 1
          no_function_module = 2
          others             = 3.
      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 'SSF_OPEN'
        exporting
          user_settings      = ' '
          output_options     = output_options
          control_parameters = control_parameters.

      call function fm_name2
        exporting
          control_parameters = control_parameters
          output_options     = output_options
          v_matnr            = wa_final-matnr
          v_werks            = wa_final-swerk
          v_lgort            = wa_final-lgort
          v_sernr            = wa_final-sernr
          v_kdauf            = wa_final-vbeln
          v_kdpos            = wa_final-posnr.

      if sy-subrc eq 0.
        flag = 'X'.
      endif.

      call function 'SSF_CLOSE'.

    endif.
    clear wa_final.
  endloop.

Read only

0 Likes
1,289

Hi,

Check this code. It might help you.

loop at it_printdata into wa_final.

    check wa_final-lgort ne space .

    output_options-tddest  = pripar-pdest.
    output_options-tdimmed = pripar-primm.
    output_options-tdnewid = 'X'.
    output_options-tdcopies = wa_final-prcop.
    append output_options.

    control_parameters-preview   = ' '.
    control_parameters-no_open   = 'X'.
    control_parameters-no_close  = 'X'.
    control_parameters-no_dialog = 'X'.
    append control_parameters.


    if wa_final-type eq 'MTS'.

*     IF wa_final-vbeln EQ space AND  wa_final-kdpos IS INITIAL.
      call function 'SSF_FUNCTION_MODULE_NAME'
        exporting
          formname           = p_form1
        importing
          fm_name            = fm_name1
        exceptions
          no_form            = 1
          no_function_module = 2
          others             = 3.
      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 'SSF_OPEN'
        exporting
          user_settings      = ' '
          output_options     = output_options
          control_parameters = control_parameters.

      call function fm_name1
        exporting
          control_parameters = control_parameters
          output_options     = output_options
          v_matnr            = wa_final-matnr
          v_werks            = wa_final-swerk
          v_lgort            = wa_final-lgort
          v_sernr            = wa_final-sernr.
      if sy-subrc eq 0.
        flag = 'X'.
      endif.
      call function 'SSF_CLOSE'.

    else.

      check wa_final-vbeln ne space and not wa_final-posnr is initial .

      call function 'SSF_FUNCTION_MODULE_NAME'
        exporting
          formname           = p_form2
        importing
          fm_name            = fm_name2
        exceptions
          no_form            = 1
          no_function_module = 2
          others             = 3.
      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 'SSF_OPEN'
        exporting
          user_settings      = ' '
          output_options     = output_options
          control_parameters = control_parameters.

      call function fm_name2
        exporting
          control_parameters = control_parameters
          output_options     = output_options
          v_matnr            = wa_final-matnr
          v_werks            = wa_final-swerk
          v_lgort            = wa_final-lgort
          v_sernr            = wa_final-sernr
          v_kdauf            = wa_final-vbeln
          v_kdpos            = wa_final-posnr.

      if sy-subrc eq 0.
        flag = 'X'.
      endif.

      call function 'SSF_CLOSE'.

    endif.
    clear wa_final.
  endloop

.

Read only

0 Likes
1,289

Hi Balu,

Thanks for the reply but this is not what im looking for. I need to pass raw data to the printer

david