Mass issuing of Outputs

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

Post Reply
new2sapfans
Posts: 71
Joined: Thu Jan 01, 2009 11:01 am

Mass issuing of Outputs

Post by new2sapfans » Wed Feb 11, 2009 5:23 am

We've got 200 test sales orders set up in our QA box, and I need to issue the Order Ack and Order Conf outputs on each of these.

VF31 does a mass printing of any output type on any number of billing documents.
Is there a similar transaction for issuing any number of output on any number of sales orders?
Or is a custom program the only way out?

YuriT
Posts: 885
Joined: Fri Feb 03, 2006 6:40 am
Location: Basel/Riga

Re: Mass issuing of Outputs

Post by YuriT » Wed Feb 11, 2009 9:38 am

Try RSNAST00 program

new2sapfans
Posts: 71
Joined: Thu Jan 01, 2009 11:01 am

Re: Mass issuing of Outputs

Post by new2sapfans » Thu Mar 05, 2009 12:26 pm

I finally had to do some nasty things to the NAST table
I still cannot suppress the pop up at every SUBMIT, and so have to hit enter as many times as the number of outputs.
Can someone pls help?

Code: Select all



REPORT  ZVF31.
TABLES : TNAPR, VBPA.

DATA:  RETURNCODE   LIKE SY-SUBRC,
       US_SCREEN TYPE C,
       GV_VBELN LIKE VBAK-VBELN,
       GV_KAPPL LIKE NAST-KAPPL,
       GV_OBJKY LIKE NAST-OBJKY,
       GV_KSCHL LIKE NAST-KSCHL,
       GV_NACHA LIKE NAST-NACHA,
       GV_NUMC(10) TYPE N,
       WA_NAST  LIKE NAST,
       WA_NAST_INS LIKE NAST. "USED FOR INSERT

RANGES: RA_KAPPL FOR GV_KAPPL,
        RA_OBJKY FOR GV_OBJKY,
        RA_KSCHL FOR GV_KSCHL,
        RA_NACHA FOR GV_NACHA.

PARAMETERS : P_KAPPL LIKE NAST-KAPPL OBLIGATORY DEFAULT 'V1',
             P_KSCHL LIKE NAST-KSCHL OBLIGATORY DEFAULT 'BA00',
             P_NACHA LIKE NAST-NACHA OBLIGATORY DEFAULT '1'. "MEDIUM

SELECT-OPTIONS : S_VBELN FOR  GV_VBELN OBLIGATORY.

PARAMETERS P_DEVICE LIKE NAST-LDEST OBLIGATORY DEFAULT 'LP01'.
START-OF-SELECTION.

  SELECT SINGLE *
    FROM TNAPR
    INTO TNAPR
   WHERE KSCHL EQ P_KSCHL
     AND NACHA EQ P_NACHA
     AND KAPPL EQ P_KAPPL.

CHECK SY-SUBRC EQ 0.
  LOOP AT S_VBELN.
    GV_NUMC = S_VBELN-LOW.
    SELECT  *
      FROM NAST
      UP TO 1 ROWS
      INTO WA_NAST
     WHERE KAPPL EQ P_KAPPL
       AND OBJKY EQ GV_NUMC
       AND KSCHL EQ P_KSCHL
       "AND SPRAS EQ 'EN'
       AND NACHA EQ P_NACHA.
    ENDSELECT.
    IF SY-SUBRC EQ 0.
      IF WA_NAST-VSTAT EQ '1' or
         WA_NAST-VSTAT EQ '2' . "OUTPUT ALREADY PROCESSED FOR THIS
        "so create a new NAST record
        WA_NAST_INS = WA_NAST.
        WA_NAST_INS-ERDAT = SY-DATUM.
        WA_NAST_INS-ERUHR = SY-UZEIT.
        WA_NAST_INS-TCODE = 'ZVF31'.
        WA_NAST_INS-MANUE = 'X'.
        WA_NAST_INS-USNAM = SY-UNAME.
        WA_NAST_INS-VSTAT = '0'.
        WA_NAST_INS-VSZTP = '1'.
        INSERT NAST FROM WA_NAST_INS.
        IF SY-SUBRC EQ 0.
          COMMIT WORK AND WAIT.
          PERFORM SUBMIT_RSNAST00.
        ELSE.
          format color COL_NEGATIVE INTENSIFIED on.
          write : 'Error - could not insert NAST for ', wa_nast_ins-kschl,
                    'for ', wa_nast_ins-objky.
          format reset.
        endif.
      ELSEIF WA_NAST-VSTAT EQ '0'.
        "Output not yet processed, so UPDATE NAST
        WA_NAST_INS = WA_NAST.
        WA_NAST_INS-VSZTP = '1'.
        WA_NAST_INS-USNAM = SY-UNAME.
        WA_NAST_INS-TCODE = 'ZVF31'.
        WA_NAST_INS-MANUE = 'X'.
        UPDATE NAST FROM WA_NAST_INS.
        IF SY-SUBRC EQ 0.
          COMMIT WORK AND WAIT.
          PERFORM SUBMIT_RSNAST00.
        ELSE.
          format color COL_NEGATIVE INTENSIFIED on.
          write : 'Error - could not UPDATE NAST for ', wa_nast_ins-kschl,
                    'for ', wa_nast_ins-objky.
          format reset.
        endif.
      ENDIF.
    ELSE.
      "no output proposed on the document yet, so create a new proposal
      SELECT *
        FROM VBPA
        UP TO 1 ROWS
       WHERE VBELN EQ GV_NUMC
         AND PARVW EQ 'AG'.
      ENDSELECT.
      IF SY-SUBRC EQ 0.
        WA_NAST_INS-KAPPL = P_KAPPL.
        WA_NAST_INS-OBJKY = GV_NUMC.
        WA_NAST_INS-KSCHL = P_KSCHL.
        WA_NAST_INS-SPRAS = SY-LANGU.
        WA_NAST_INS-NACHA = P_NACHA.
        WA_NAST_INS-PARNR = VBPA-KUNNR.
        WA_NAST_INS-PARVW = 'AG'.
        WA_NAST_INS-ERDAT = SY-DATUM.
        WA_NAST_INS-ERUHR = SY-UZEIT.
        WA_NAST_INS-TCODE = 'ZVA31'.
        WA_NAST_INS-MANUE = 'X'.
        WA_NAST_INS-USNAM = SY-UNAME.
        WA_NAST_INS-VSTAT = '0'.
        WA_NAST_INS-VSZTP = '1'.
        INSERT NAST FROM WA_NAST_INS.
        IF SY-SUBRC EQ 0.
          COMMIT WORK AND WAIT.
          PERFORM SUBMIT_RSNAST00.
        ELSE.
          format color COL_NEGATIVE INTENSIFIED on.
          write : 'Error - could not insert NAST for ', wa_nast_ins-kschl,
                    'for ', wa_nast_ins-objky.
          format reset.
        endif.
      ELSE.
        Format color COL_NEGATIVE INTENSIFIED on.
          write : 'Error - could not insert NAST for ', wa_nast_ins-kschl,
                    'for ', wa_nast_ins-objky.
          format reset.
      ENDIF.
    ENDIF.
  ENDLOOP.

  FORM SUBMIT_RSNAST00.
    REFRESH : RA_KAPPL, RA_OBJKY, RA_KSCHL, RA_NACHA.
    CLEAR   : RA_KAPPL, RA_OBJKY, RA_KSCHL, RA_NACHA.

    RA_KAPPL-SIGN = 'I'.
    RA_KAPPL-OPTION = 'EQ'.
    RA_KAPPL-LOW = P_KAPPL.
    APPEND RA_KAPPL.

    RA_OBJKY-SIGN = 'I'.
    RA_OBJKY-OPTION = 'EQ'.
    RA_OBJKY-LOW = GV_NUMC.
    APPEND RA_OBJKY.

    RA_KSCHL-SIGN = 'I'.
    RA_KSCHL-OPTION = 'EQ'.
    RA_KSCHL-LOW = P_KSCHL.
    APPEND RA_KSCHL.

    RA_NACHA-SIGN = 'I'.
    RA_NACHA-OPTION = 'EQ'.
    RA_NACHA-LOW = P_NACHA.
    APPEND RA_NACHA.

    SUBMIT RSNAST00 WITH S_KAPPL IN RA_KAPPL
                WITH S_OBJKY IN RA_OBJKY
                WITH S_KSCHL IN RA_KSCHL
                WITH S_NACHA IN RA_NACHA
                WITH P_PRINT EQ P_DEVICE
                WITH P_SUFF2 EQ 'ZVA31' and RETURN.

    IF sy-subrc ne 0.
      FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
      write :/ 'Error - could not issue output', wa_nast_ins-kschl,
            'for ', wa_nast_ins-objky.
      FORMAT RESET.
    ELSE.
      FORMAT COLOR COL_POSITIVE INTENSIFIED ON.
      write :/ 'Successfully issued ', wa_nast_ins-kschl,
            'for ', wa_nast_ins-objky.
      FORMAT RESET.
    ENDIF.

  ENDFORM.

Dr Sidewalk
Posts: 3531
Joined: Mon Oct 21, 2002 11:06 am
Location: Everywhere...

Re: Mass issuing of Outputs

Post by Dr Sidewalk » Fri Mar 06, 2009 2:08 am

I have a vague feeling that this question, or something very similar, has been asked before, although I have not been abale to find the posting myself.

Dr Sidewalk
"In the middle of difficulty lies opportunity" - Albert Einstein
"Money isn't everything in life, unless you don't have it"
"Fail to plan, plan to fail"
"Success is a journey, not a destination."

Post Reply