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

Custom Sapscript print program..

Former Member
0 Kudos

Hi ABAP Gurus,

I am working on Creation of new custom SAPScript driver(print) program for shop floor.

I know the functions to be used while creating new SAPScript driver program.

But can someone provide me with sample two or three sample custom SAPScript print porgrams (Not the SAP Standard print programs)?

It would be a great help since I can see how exactly they are being structured.

My email ID is <b></b>

I will surely award full points for it.



Developer Advocate
Developer Advocate
0 Kudos

Here is copy of our version of the shop floor paper for PP01 orders. Notice the IMPORT statement at the beginning of the program. This is really all you need from the standard program.

report zpsfcopct message-id co.

type-pools: co.

data: caufvd_tab  type caufvd occurs 0 with header line,
      afpod_tab   type afpod occurs 0 with header line,
      afvgd_tab   type afvgd occurs 0 with header line,
      affld_tab   type affld occurs 0 with header line,
      resbd_tab   type resbd occurs 0 with header line,
      affhd_tab   type affhd occurs 0 with header line,
      work_tab    type co_rcr01_tab with header line,
      mv_tab      type co_sfcmatdr_tab with header line,
      afdld_tab   type co_afdld_tab with header line,
      kbedp_tab   type co_kbedp_tab with header line,
      stpub       type stpub occurs 0 with header line,
      colord_tab  type co_ppprcolord_tab with header line,
      serob_tab   type co_rserob_tab with header line,
      fhm_tab     type affhd occurs 0 with header line,
      charac_tab  type co_sfc_conf_tab with header line,
      ttl_tab     type co_sfcttl_act_tab with header line,
      cobl        type cobl.

data: begin of formdata,
      aufnr type caufv-aufnr,
      gstrp type caufv-gstrp,
      gltrp type caufv-gltrp,
      cy_seqnr type caufv-cy_seqnr,
      kdauf(10) type n,
      kdpos(6)  type n,
      vbeln type vbap-vbeln,
      posnr type vbap-posnr,
      vbelv type vbfa-vbelv,
      kwmeng type vbap-kwmeng,
      kunnr type kna1-kunnr,
      name1 type kna1-name1,
      route type vbap-route,
      matnr type vbap-matnr,
      matwa type vbap-matwa,
      arktx type vbap-arktx,
      matds type makt-maktx,
      mdext type makt-maktx,
      optxt type makt-maktx,
      cuobj type vbap-cuobj,
      pgmng type afpo-pgmng,
      vtext type tvsbt-vtext,
      txt01 type tline-tdline,
      txt02 type tline-tdline,
      txt03 type tline-tdline,
      txt04 type tline-tdline,
      end of formdata.

* Start of mainline


  perform print_routine.

*      Form  print_routine
form print_routine.

  data: prlst_tmp like print_co.

* Import values from calling program.
  import prlst_tmp  from memory id 'PPS'.

* get document-tables from memory
  import caufvd_tab "headers
         afpod_tab  "positions
         affld_tab  "sequences
         afvgd_tab  "operations/suboperations
         resbd_tab  "components
         affhd_tab  "PRTs
         work_tab   "workcenters sorted by arbid werks
         mv_tab     "material view sorted by matnr werks
         charac_tab "configuration sorted by cuobj
         kbedp_tab  "capacity request sorted by bedid bedzl
         colord_tab "collective order info sorted by aufnr
         ttl_tab    "activities sorted by aufpl aplzl
         serob_tab  "serialnumbers sorted by ppaufnr ppposnr sernr
         afdld_tab  "document links
                        from memory id 'PPT'.

  clear formdata.
* Read header data from import and begin processing
  read table caufvd_tab index 1.

  check sy-subrc = 0.

  perform retrieve_all_data using caufvd_tab-aufnr.

  do prlst_tmp-copys times.        " Should only ever be 1
    perform print_sapscript_form using prlst_tmp.


*      Form  retrieve_all_data
form retrieve_all_data using p_aufnr.

* Structures
  data:  xcaufv  like caufv,
         xafpo   like afpo,
         xvbak   like vbak,
         xvbap   like vbap,
         xvbpa   like vbpa,
         xvbfa   like vbfa,
         xkna1   like kna1,
         xadrc   like adrc,
         xtvsbt  like tvsbt,
         xmara   like mara,
         xzctbna like zctbna.

  data: begin of imods occurs 0,
        atwrt type comw-atwrt,
        end of imods.

  data: begin of iedgeloc occurs 0,
        atwrt type comw-atwrt,
        end of iedgeloc.

  data: edgeshape type comw-atwrt.

* Hit production order header(AUFK, AFKO)
  select single * into corresponding fields of xcaufv
                  from caufv
                        where aufnr = p_aufnr.

* Hit production order item
  select single * into corresponding fields of xafpo
                  from afpo
                        where aufnr = xcaufv-aufnr.

* Hit sales document header
  select single * into corresponding fields of xvbak
                  from vbak
                        where vbeln = xafpo-kdauf.

* Hit sales document item
  select single * into corresponding fields of xvbap
                  from vbap
                        where vbeln = xafpo-kdauf
                          and posnr = xafpo-kdpos.

* Hit the shipping conditions text table
  select single * into corresponding fields of xtvsbt
                  from tvsbt
                        where vsbed = xvbak-vsbed
                          and spras = sy-langu.

* Hit material master
  select single * into corresponding fields of xmara
                  from mara
                        where matnr = xafpo-matnr.

* Hit customer master with sold-to
  select single * into corresponding fields of xkna1
                  from kna1
                        where kunnr = xvbak-kunnr.

* Hit ship-to informations
  select single * into corresponding fields of xvbpa
                  from vbpa
                        where vbeln = xafpo-kdauf
                          and parvw = 'WE'.

* Hit dynamic address table for ship to name.
  select single * into corresponding fields of xadrc
                  from adrc
                        where addrnumber = xvbpa-adrnr
                          and date_to = '99991231'.

* Hit the document flow table to get the inquiry number
  select single * into xvbfa
            from vbfa
                  where vbeln = xvbap-vbeln
                    and posnn = xvbap-posnr.

* Fill form fields
  formdata-aufnr = xcaufv-aufnr.
  formdata-gstrp = xcaufv-gstrp.
  formdata-gltrp = xcaufv-gltrp.
  formdata-kdauf = xcaufv-kdauf.
  formdata-kdpos = xcaufv-kdpos.
  formdata-cy_seqnr = xcaufv-cy_seqnr.
  formdata-vbeln = xvbap-vbeln.
  formdata-posnr = xvbap-posnr.
  formdata-vbelv = xvbfa-vbelv.
  formdata-kwmeng = xvbap-kwmeng.
  formdata-kunnr = xvbak-kunnr.
  formdata-name1 = xadrc-name1.
  formdata-route = xvbap-route.
  formdata-matnr = xvbap-matnr.
  formdata-matwa = xvbap-matwa.
  formdata-arktx = xvbap-arktx.
  formdata-cuobj = xvbap-cuobj.
  formdata-pgmng = xafpo-pgmng.
  formdata-vtext = xtvsbt-vtext.
  formdata-cartb = xzctbna-cartb.

* Determine item description
  case xmara-mtart.
    when 'ZCFG'.
      if xvbap-matwa = xvbap-matnr
        or xvbfa-vbelv <> space.
        formdata-matds = xvbap-arktx.
        formdata-matds = xvbap-matwa.
    when 'FERT'.
      formdata-matds = xvbap-matnr.
    when others.
      formdata-matds = xvbap-matnr.

*      Form  print_sapscript_form
form print_sapscript_form using p_printco.

  data: itcpo like itcpo.
  data: print_co like print_co.

  print_co = p_printco.

  call function 'CO_DR_PR_OPT_FILL'
            prt_co = print_co
            pr_opt = itcpo.

  call function 'OPEN_FORM'
            device   = 'PRINTER'
            dialog   = ' '
            form     = print_co-forml
            language = print_co-spras
            options  = itcpo
            canceled = 01
            device   = 02
            form     = 03
            options  = 04
            unclosed = 05.

  call function 'START_FORM'
            startpage = 'PAGE1'
            others    = 7.

  call function 'WRITE_FORM'
            window = 'MAIN'
            others = 9.

* End the form.
  call function 'END_FORM'
            others = 4.

* Close the form.
  call function 'CLOSE_FORM'
            others = 01.



Rich Heilman