Saturday, 17 September 2016

Example : Invoice

Steps :-

  • Go to Transaction code SMARTFORMS.


To create form

  • Select radio button as Form and enter the form name start's with Y or Z< form name > .
  • Click on Create.
  • Initial screen looks like,

To design form

  • Click on Form Painter.
  • Initial page looks like.

To create a window.

  • Right Click on page ->create ->  window.

  • Window looks like,

  • Adjust the width , height , Left Margin  and Upper Margin of window using drag and drop.


To rename the window 

  • Click on Form Painter.

  • Rename.

  • Similarly , design the page.

  • Click on Save.
  • Pop up will appear.
  • Assign Package.
  • Click on Form Painter.

Implementation

To create Paragraph Format and Character Format.

  • Click on Style Radio button and enter the Style name which start's with Y or Z< Style name > .
  • Click on Create .
  • Looks like,

To create Paragraph format

Heading Paragraph Format.

  • Right click on paragraph format -> Create node.

  • Pop-up will appear.
  • Enter the Paragraph format name and click on Enter.

  • Enter the Description and select the Alignment.

  • Click on Font Tab.
  • Select the Font Family , Font Size , Font Style , Color.

Side Heading Paragraph Format.

  • Right click on paragraph format -> Create node.
  • Pop-up will appear.
  • Enter the Paragraph format name and click on Enter.
  • Enter the Description and Indent.
  • Click on Font Tab.
  • Select the Font Family , Font Size , Font Style , Color.

Default Paragraph Format.

  • Right click on paragraph format -> Create node.

  • Pop-up will appear.
  • Enter the Paragraph format name and click on Enter.
  • Enter the Description and Indent.
  • Click on Font Tab.
  • Select the Font Family , Font Size , Font Style , Color.

=============

  • Double click on Header Data.

  • Select the standard paragraph ( Default ).

  • Save -> Check -> Activate.

  • Copy the Style name.
  • Go back to Form.

  • Click on Output Options and enter the Style name.




Header

  • Right click on HEAD window -> Create -> Text.
  • Looks like ,
  • Click on  " General Attributes " tab.
  • Click on Goto -> Change Editor.
  • Select the paragraph format and Enter the Text.

  • Click on Back button.

  • Double Click on HEAD Window.
  • Click on Output Options Tab.
  • Enable Frames line with , Shadings.
  • Save -> Check -> Activate.

Test

  • Click on Test.
  • Automatically Function Module will generates.
  • Click on Test.

  • Click on Execute.

  • Pop will appear.
  • Click on Print preview.


Output



Logo


  • Go back to form.
  • Right click on LOGO window -> Create -> Graphic.


  • Click on Name  F4 help.
  • Pop-up will appear.
  • Enter the uploaded Image name and select color Bitmap Image.
  • Click on Execute.

  • Pop-up will appear.
  • Select the Image.
  • Looks like,
  • Save -> Check -> Activate.


Test




Ship to address

  • Go to transaction code SE38 to write Driver program .
  • Enter the program name which start's with Y or Z< program name > and click on Create.
  • Pop-up will appear.
  • Select Attribute Type as Executable Program.
  • Click on SAVE.

  • Enter the Source code.
TYPES : BEGIN OF TY_VBRK,
        VBELN TYPE VBRK-VBELN,            " BILLING  HEADER DATA
        KUNAG TYPE VBRK-KUNAG,
        END OF TY_VBRK.
        
TYPES : BEGIN OF TY_KNA1,
        KUNNR TYPE KNA1-KUNNR,             " CUSTOMER
        ADRNR TYPE KNA1-ADRNR,
        END OF TY_KNA1.


DATA : WA_VBRK TYPE TY_VBRK,
       WA_KNA1 TYPE TY_KNA1.


PARAMETERS : P_VBELN TYPE VBRK-VBELN.

START-OF-SELECTION.

PERFORM FETCH_DATA.
*&---------------------------------------------------------------------*
*&      Form  FETCH_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FETCH_DATA .
  
  SELECT SINGLE VBELN KUNAG FROM VBRK INTO WA_VBRK WHERE VBELN = P_VBELN.
    
  SELECT SINGLE KUNNR ADRNR FROM KNA1 INTO WA_KNA1 WHERE KUNNR = WA_VBRK-KUNAG.
    

ENDFORM.                    " FETCH_DATA

  • Create global structure using Transaction Code SE11.
  • Go to Smartforms.
  • Click on Form Interface and pass the import parameter.
  • Click on SHIPTO window.
  • Click on Output Option.
  • Enable Frames with Line.

  • Right click on SHIPTO window -> Create -> Address.

  • Double click on Address.


  • Click on Form painter.

  • Click on Address Number's Dynamic Field Value.
  • Pass the Address Number variable .
  • Right click on SHIPTO window -> Create -> Text.
  • Enter the side heading and select the paragraph format.

  • Save -> Check -> Activate.
  • Click on Test.

  • Copy the Function Module name.
  • Go back to Diver program.
  • Call the function module using Pattern.
  • Pass the Exporting Value.

TYPES : BEGIN OF TY_VBRK,
        VBELN TYPE VBRK-VBELN,            " BILLING  HEADER DATA
        KUNAG TYPE VBRK-KUNAG,
        END OF TY_VBRK.

TYPES : BEGIN OF TY_KNA1,
        KUNNR TYPE KNA1-KUNNR,             " CUSTOMER
        ADRNR TYPE KNA1-ADRNR,
        END OF TY_KNA1.


DATA : WA_VBRK TYPE TY_VBRK,
       WA_KNA1 TYPE TY_KNA1.


PARAMETERS : P_VBELN TYPE VBRK-VBELN.

START-OF-SELECTION.

PERFORM FETCH_DATA.

PERFORM CALL_FORM.
*&---------------------------------------------------------------------*
*&      Form  FETCH_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FETCH_DATA .

  SELECT SINGLE VBELN KUNAG FROM VBRK INTO WA_VBRK WHERE VBELN = P_VBELN.

  SELECT SINGLE KUNNR ADRNR FROM KNA1 INTO WA_KNA1 WHERE KUNNR = WA_VBRK-KUNAG.


ENDFORM.                    " FETCH_DATA
*&---------------------------------------------------------------------*
*&      Form  CALL_FORM
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM CALL_FORM .

  CALL FUNCTION '/1BCDWB/SF00000189'
    EXPORTING
*     ARCHIVE_INDEX              =
*     ARCHIVE_INDEX_TAB          =
*     ARCHIVE_PARAMETERS         =
*     CONTROL_PARAMETERS         =
*     MAIL_APPL_OBJ              =
*     MAIL_RECIPIENT             =
*     MAIL_SENDER                =
*     OUTPUT_OPTIONS             =
*     USER_SETTINGS              = 'X'
      WA_KNA1F                   = WA_KNA1
*   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.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


ENDFORM.                    " CALL_FORM

  • Save -> Check -> Activate.

Test

  • Click on Execute.
  • Enter Billing document Number.

  • Execute.
  • Pop-up will appear.
  • Click on Print-preview.

Output


Bill to Address

  • Go to Driver program.
  • Fetch the Bill to Customer Address  Number.

Source Code


TYPES : BEGIN OF TY_VBRK,
        VBELN TYPE VBRK-VBELN,            " BILLING  HEADER DATA
        KUNAG TYPE VBRK-KUNAG,
        KUNRG TYPE VBRK-KUNRG,
        END OF TY_VBRK.

TYPES : BEGIN OF TY_KNA1,
        KUNNR TYPE KNA1-KUNNR,             " CUSTOMER
        ADRNR TYPE KNA1-ADRNR,
        END OF TY_KNA1.


DATA : WA_VBRK TYPE TY_VBRK,
       WA_KNA1 TYPE TY_KNA1,
       WA_KNA2 TYPE TY_KNA1.


PARAMETERS : P_VBELN TYPE VBRK-VBELN.

START-OF-SELECTION.

PERFORM FETCH_DATA.

PERFORM CALL_FORM.
*&---------------------------------------------------------------------*
*&      Form  FETCH_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FETCH_DATA .

  SELECT SINGLE VBELN KUNAG KUNRG FROM VBRK INTO WA_VBRK WHERE VBELN = P_VBELN.

  SELECT SINGLE KUNNR ADRNR FROM KNA1 INTO WA_KNA1 WHERE KUNNR = WA_VBRK-KUNAG.

   SELECT SINGLE KUNNR ADRNR FROM KNA1 INTO WA_KNA2 WHERE KUNNR = WA_VBRK-KUNRG.

ENDFORM.                    " FETCH_DATA

  • Go to SMARTFORMS .
  • Click on Form Interface.
  • Enter the Import parameter.
  • Double click on BILLTO window.
  • Click on Output Options.
  • Enable Frames with Line.
  • Right click on BILLTO window -> Create -> Text.
  • Click on General Attributes tab.
  • Enter the text as well as paragraph format.
  • Right click on BILLTO window -> Create -> Address.
  • Pass the Bill to party Address Number.
  • Arrange it properly ( Drag and Drop ).

  • Save -> Check -> Activate.
  • Click on Test.
  • Copy the function Module name.
  • Go to Driver program .
  • Call the function module using pattern and pass the Exporting parameters.

  • Save -> Check -> Activate.

Test

  • Click on Execute.


Input

  • Enter the input.

Output




Sales Organization 

  • Go back to Driver Program .

Source code


TYPES : BEGIN OF TY_VBRK,
        VBELN TYPE VBRK-VBELN,            " BILLING  HEADER DATA
        KUNAG TYPE VBRK-KUNAG,
        KUNRG TYPE VBRK-KUNRG,
        VKORG TYPE VBRK-VKORG,
        END OF TY_VBRK.

TYPES : BEGIN OF TY_KNA1,
        KUNNR TYPE KNA1-KUNNR,             " CUSTOMER
        ADRNR TYPE KNA1-ADRNR,
        END OF TY_KNA1.

TYPES : BEGIN OF TY_TVKO,
        VKORG TYPE TVKO-VKORG,
        WAERS TYPE TVKO-WAERS,    "Sales Organization
        ADRNR TYPE TVKO-ADRNR,
        KUNNR TYPE TVKO-KUNNR,

        END OF TY_TVKO.

DATA : WA_VBRK TYPE TY_VBRK,
       WA_KNA1 TYPE TY_KNA1,
       WA_KNA2 TYPE TY_KNA1,
       WA_TVKO TYPE TY_TVKO.


PARAMETERS : P_VBELN TYPE VBRK-VBELN.

START-OF-SELECTION.

PERFORM FETCH_DATA.

PERFORM CALL_FORM.
*&---------------------------------------------------------------------*
*&      Form  FETCH_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FETCH_DATA .

  SELECT SINGLE VBELN KUNAG KUNRG VKORG FROM VBRK INTO WA_VBRK WHERE VBELN = P_VBELN.

  SELECT SINGLE KUNNR ADRNR FROM KNA1 INTO WA_KNA1 WHERE KUNNR = WA_VBRK-KUNAG.

   SELECT SINGLE KUNNR ADRNR FROM KNA1 INTO WA_KNA2 WHERE KUNNR = WA_VBRK-KUNRG.

  SELECT SINGLE VKORG
                WAERS
                ADRNR
                KUNNR

                FROM TVKO INTO WA_TVKO WHERE VKORG = WA_VBRK-VKORG.

ENDFORM.                    " FETCH_DATA

  • Create a structure in SE11.

  • Save -> Check -> Activate.
  • Copy the structure name.
  • Go to SMARTFORMS .
  • Double click Form Attributes .
  • Pass the import parameter.



No comments:

Post a Comment