How to assign custom purchase order smartforms to NACE output type in sap




When we click on print preview in sap ME22N transaction for PO print preview 


We can see the print preview 




This print come as per the form assign to message type in NACE.
First check the message in  ME22N 


Click on messages

                              

We can see the message type is NEU
Now we will check which driver program and sap script or smartforms is assign to this output type.

Go to Transaction : NACE


select the application EF and click on output types.


select the output type NEU and click on processing routines.


we can see the program SAPFM06P is assign with form routine ENTRY_NEU and the 
sap script MEDRUCK   
   
The main program  SAPFM06P contain the include FM06PE02 which has the routine ENTRY_NEU

Now to assign the custom smartform , we have copy this standard main program along with include to Z program.

let say main program 
SAPFM06P is copy to ZK_SAPFM06P  and its include 
FM06PE02 is copy to ZK_FM06PE02

now inside this include program add the logic to call the smartforms .

Original code of include FM06PE02 routine ENTRY_NEU

form entry_neu using ent_retco ent_screen.

  datal_druvo like t166k-druvo,
        l_nast  like nast,
        l_from_memory,
        l_doc   type meein_purchase_doc_print.

  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.
  call function 'ME_PRINT_PO'
       exporting
            ix_nast        l_nast
            ix_druvo       l_druvo
            doc            l_doc
            ix_screen      ent_screen
            ix_from_memory l_from_memory
            ix_toa_dara    toa_dara
            ix_arc_params  arc_params
            ix_fonam       tnapr-fonam          "HW 214570
       importing
            ex_retco       ent_retco.
endform.

This code to be replace as below to call the smartforms.

Note in my smartforms I am taking only PO number from NAST as input and passing this PO number to smartforms.

FORM ENTRY_NEU USING ENT_RETCO ENT_SCREEN.

  DATAL_DRUVO       LIKE T166K-DRUVO,
        L_NAST        LIKE NAST,
        L_FROM_MEMORY,
        L_DOC         TYPE MEEIN_PURCHASE_DOC_PRINT.

  DATA FM_NAME            TYPE  RS38L_FNAM,
         CONTROL_PARAMETERS TYPE  SSFCTRLOP,
         OUTPUT_OPTIONS     TYPE  SSFCOMPOP,
         GV_EBELN           TYPE EBELN.



  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 tnapr-sform NE ' '.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  EXPORTING
    FORMNAME                 tnapr-sform       "'ZDEMO_PO1'
*   VARIANT                  = ' '
*   DIRECT_CALL              = ' '
 IMPORTING
   FM_NAME                  FM_NAME
 EXCEPTIONS
   NO_FORM                  1
   NO_FUNCTION_MODULE       2
   OTHERS                   3
          .
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

   CONTROL_PARAMETERS-PREVIEW    'X'.
   CONTROL_PARAMETERS-NO_DIALOG  'X'.

   OUTPUT_OPTIONS-TDDEST 'LP01'.

   gv_ebeln L_NAST-OBJKY.

 CALL FUNCTION FM_NAME                       "'/1BCDWB/SF00000264'
  EXPORTING
*    ARCHIVE_INDEX              =
*    ARCHIVE_INDEX_TAB          =
*    ARCHIVE_PARAMETERS         =
    CONTROL_PARAMETERS         CONTROL_PARAMETERS
*    MAIL_APPL_OBJ              =
*    MAIL_RECIPIENT             =
*    MAIL_SENDER                =
    OUTPUT_OPTIONS             OUTPUT_OPTIONS
    USER_SETTINGS              'X'
    IP_EBELN                   gv_ebeln
*  IMPORTING
*    DOCUMENT_OUTPUT_INFO       =
*    JOB_OUTPUT_INFO            =
*    JOB_OUTPUT_OPTIONS         =
  EXCEPTIONS
    FORMATTING_ERROR           1
    INTERNAL_ERROR             2
    SEND_ERROR                 3
    USER_CANCELED              4
    OTHERS                     5
           .
 IF SY-SUBRC <> 0.
* Implement suitable error handling here
 ENDIF.


  ELSE.


  CALL FUNCTION 'ME_PRINT_PO'
    EXPORTING
      IX_NAST        L_NAST
      IX_DRUVO       L_DRUVO
      DOC            L_DOC
      IX_SCREEN      ENT_SCREEN
      IX_FROM_MEMORY L_FROM_MEMORY
      IX_TOA_DARA    TOA_DARA
      IX_ARC_PARAMS  ARC_PARAMS
      IX_FONAM       TNAPR-FONAM          "HW 214570
    IMPORTING
      EX_RETCO       ENT_RETCO.


  ENDIF.

ENDFORM.

Now assign this customized main program and smartforms to output type NEU in NACE


Save the details.
Now again to to ME22N and click on print preview


Check the print


In this way, we can assign the custom smartforms to standard/custom output type in NACE 


























Post a Comment

0 Comments

Total Pageviews