Monday, November 27, 2017

Adobe Form Overview

Adobe Form is an interactive form in PDF that allow user to fill out the form in screen and save  entries in XML format in the form. When the SAP system receives the form, it extract the data saved in the form and can process further.

The forms are composed of Master Pages and Body Pages.

Context:
  • The text include module cannot refer to an import, it only can refer to a global variable.

What’s in the form design?
The following components make up a form design:
  1. Master pages: Provides the layout and format for pages in the form.
The Master Pages defines the global elements as Header/footer/pages/format/orientation…
The master pages contains « Content Area ».
This content area will take the Body Pages. It can be resized

In general we create only 1 master page except in the case we have many formats or orientation
  1. Body pages: Represent the page of a form. You can choose which master page to assign to the body page. Header, Item detail, Footer are defined in body page.
  2. Content areas
  3. Subforms: Container that you can use to group design objects such as fields, images, address etc. You can set the properties of subform, it will then apply to all objects within the subform.
  4. Fields
  5. Boilerplate objects
    1. Text Field (Text with caption - caption can be translated to different languages by Edit → Translation)
      1. You can remove the caption in the text field is changing its caption position to none using Layout tab of the object properties window.
    2. Text: Display only text
    3. Floating Field

Palettes
  1. Hierarchy palettes is a visual presentation of the contents in body pages and master pages tabs. The palettes also display objects added to the form under the object node.
  2. Data View palettes is a visualization to provide a way of mapping data from context to the form. You can drag & drop fields from Data View to the form.
  3. Object palettes
  4. Layout palettes

Layout settings: Expand to fit

Thursday, November 23, 2017

Q&A (Adobe Form)

How to access a context data in Javascript?
use a hidden field and read the value from this hidden field.

How to create table?

Create subform by dragging internal table from the data layout tab
In binding, choose "use name <subform>"
The table is automatically created and displayed

How to create table with alternative?
Create 2 tables and alternatively hide the table using script by a condition.

How to call adobe form from driver program?
The 5 basic steps involved are -
 1.Data retrieval in the report programme.
 2.Call Function 'FP_FUNCTION _MODULE_NAME( to get the  generated
    function module name).
 3.Call Function 'FP_JOB_OPEN '.
 4.Call Function <generated function module name>.
 5.Call Function 'FP_JOB_CLOSE'.

Example:
DATA: CUSTOMER          TYPE SCUSTOM,
      BOOKINGS          TYPE TY_BOOKINGS,
      CONNECTIONS       TYPE TY_CONNECTIONS,
      FM_NAME           TYPE RS38L_FNAM,
      FP_DOCPARAMS      TYPE SFPDOCPARAMS,
      FP_OUTPUTPARAMS   TYPE SFPOUTPUTPARAMS.
 
 
* GETTING THE DATA
  <data selection>
 
 
* PRINT:
 
* Sets the output parameters and opens the spool job
    CALL FUNCTION 'FP_JOB_OPEN'
     CHANGING
     IE_OUTPUTPARAMS       = FP_OUTPUTPARAMS
     EXCEPTIONS
     CANCEL                = 1
     USAGE_ERROR           = 2
     SYSTEM_ERROR          = 3
     INTERNAL_ERROR        = 4
     OTHERS                = 5.
    IF SY-SUBRC <> 0.
  <error handling>
    ENDIF.
 
* Get the name of the generated function module
   CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
    EXPORTING
    I_NAME                     = '<form name>'
    IMPORTING
    E_FUNCNAME                 = FM_NAME.
   IF SY-SUBRC <> 0.
  <error handling>
   ENDIF.
 
* Call the generated function module
   CALL FUNCTION FM_NAME
     EXPORTING
     /1BCDWB/DOCPARAMS        = FP_DOCPARAMS
     CUSTOMER                 = CUSTOMER
     BOOKINGS                 = BOOKINGS
     CONNECTIONS              = CONNECTIONS
*   IMPORTING
*     /1BCDWB/FORMOUTPUT       =
    EXCEPTIONS
      USAGE_ERROR           = 1
      SYSTEM_ERROR          = 2
      INTERNAL_ERROR           = 3.
   IF SY-SUBRC <> 0.
  <error handling>
   ENDIF.
 
* Close the spool job
  CALL FUNCTION 'FP_JOB_CLOSE'
*   IMPORTING
*    E_RESULT             =
    EXCEPTIONS
      USAGE_ERROR           = 1
      SYSTEM_ERROR          = 2
      INTERNAL_ERROR        = 3
      OTHERS                = 4.
  IF SY-SUBRC <> 0.
  <error handling>
  ENDIF.

Wednesday, November 22, 2017

ENHANCEMENT-POINT Implementation

ENHANCEMENT-POINT

Points are predefined hooks available in Std SAP code which you can implement. At runtime, based on the Switch status of the Implementation, the implementations would be called.
  • INCLUDE BOUND - If point is INCLUDE BOUND, the enh implementation would be created into the include, instead of the main program.
  • STATIC – If point is STATIC, the implementation would be called if switch is not assigned. If switch is assigned, implementation would be called based on the status. If point is not STATIC, the implementation has to be part of the switch and it has to be active.

Find an Enhancement-POINT

To find any enhancement, you need to follow almost similar process like you have used to find any other enhancement – You debug. If you know the program, you can go through it and look for a specific point which you want to implement. But, I believe Debugging would give you better options.
Let take some scenario – You want to update certain attributes for Line Item while posting the material document. So, you debug the process. And found out that there is this Enhancement point which you can implement.

Implement the Enhancement-Point

1. Get to Enhancement Mod
Press the Spiral button on the toolbar to bring up the Enhancement mode. Once you are in Enhancement, the Editor would be open for change with kind of maze on left.
Enhancement_Implementation_Initial_Mode
2. Create an Enhancement
Put Cursor on the Enhancement Name and choose option Edit > Enhancement Operations > Create Implementation
Enhancement_implementation_Create_Implemenation
The same option is also available in context menu (right click)
If all options in Enhancement Operations in Main Menu and in context Menu are not selectable, you must not be in the Enhancement Mode.
3. Choose or use Implementation
System would bring you a popup to choose existing Enhancement implementation. If you implementing a new functionality, I suggest you create the new Implementation by pressing the Create Icon. Enter the details of the Enh Imp name and description. In subsequent popup enter the Package and TR if you don’t select Local objects.
Enh_Imp_Explicit_pop_1
Once Enh Imp is created, you are back to the popup to select the Enh Imp.
Enh_Imp_Explicit_pop_2
4. Implement the logic
Now Implement the logic in your Enhancement Implementation. Once completed, press Activate Enhancements to activate the implementation.
Enh_Imp_Explicit_implemented_code

Remove Implementation

If the you wish to remove the implementation, you need to follow two step approach.
  1. Undo the implementation first. Choose Context Menu > Enhancement Implementation > Undo Implementation.
  2. Activate the Implementation. If you don’t activate, the object will not be detached from the program.
  3. Go to SE80. Choose Other objects > Enhancements. Choose option Enhancement Implementation and enter the name. Choose Delete to remove it completely from system.

Multiple Implementations

There could be multiple Implementations of the same enhancement point. Like one shown in this example. If the implementation is attached to the Switch and if the switch is active, the system would execute those implementations. Implementations without any switch are also active at the same time.
If you are in the change mode of one of the implementation, Enhancement Framework will not allow you to create another one right there. You need to go out of the change mode. I generally, go out of the program and start the process again.
Enh_Imp_Explicit_implemented_multiple

Debugging Implementation

Debug the Implementation

Once you have implemented the enhancement implementation, you would be able to see it in action. To be able to debug it:
  • Put a break-point just before the implementation
  • Put a break-point within your implementation as well
  • Run your application
Enhancement_Implementation_Initial_breakpoints
If you have implemented at the correct location, debugger will stop. When debugger comes up, it would be at your 1st break-point. You would notice that your implementation is not displayed in the program. Don’t get alarmed or confused. You notice a small spiral at the beginning of the line. This Spiral shows that there is an active implementation at that location. That implementation would be called by the program when control reaches to that point.
Enhancement_Implementation_Debugger_Spiral
As you can see in this image, there is a second ENHANCEMENT-POINT which doesn’t have any active implementation. Thus there is no Spiral button in front of that.
When you step over to your breakpoint, you would be now within your implementation.
Enhancement_Implementation_Include_Name

Implementation Include

As you can notice, this implementation is in its own include. When you create the implementation for enhancement options, system generates this include to house the code. At runtime, system determines if there is any active implementation needs to be called or not. If there is, it would display that Spiral icon and call the implementation from that generated include.
System generated include name as ZTEST_NP_MAT_DOC_LINE_CHANGE==E for the implementation ZTEST_NP_MAT_DOC_LINE_CHANGE. The include name is 31 characters long. 30 chars are the name of the Implementation and filler as = for name shorter than 30 char, and 31st char as E.

How to Implement Explicit Enhancement (example #2)

In case of explicit enhancement we can add our enhancements at any place as per our requirement.
Well in our case I don't have any standard program so I am using a Z program & enhancing the code.
Before starting explicit enhancement we have to create:
  •  One enhancement spot.
  •  In enhancement spot we have to implement spot.
  •  All these task to be done under one package.
  •  So I am creating one package in se80 first.
1.   Right click & create Enhancement Spot.
2.   Give the name of Enhancement Spot
3.   Now activate the enhancement spot
4.   Right click Enhancement Spots & implement it.
5.   Activate the implementation, Goto SE38 & place the cursor where enhancement is require.
6. Enter Enhancement implementation name in Enhancement Spot name & Package name.  
 7.   Now enhancement-point will come in your code with Grey Fonts.
8.  Select Enhance
9.   Place the cursor on enhancement-point & create enhancement.
 10.    Give enhancement Implementation name.
11.  Place your code & activate.
12.  Now run the program you will find the enhancement.


Enhancement Section:
Enhancement section is used to replace a set of code or statements with the customer (custom code). In this technique the original source code does not get executed but, the customer implementation (custom code) gets executed.
Note - Explicit enhancements though can be placed anywhere in the source code but, not just anywhere except some areas where SAP would allow (program allows).
STEP 1: Create a package in transaction SE80 (Object navigator) Name YDEV
STEP 2: Navigate to 'Enhancements' folder of your package. Package (YDEV) àEnhancement.
  Right click the 'Enhancements' à 'Create' à 'Enhancement Spot'.
Description: C:\Documents and Settings\enteg12\Desktop\ppp\101.JPG
Fill in the details in the 'Create Enhancement Spot' dialog.
Description: C:\Documents and Settings\enteg12\Desktop\ppp\102.JPG
And save it into created package. Observe the enhancement spot created under the 'Enhancement Spots' folder.
Description: C:\Documents and Settings\enteg12\Desktop\ppp\ppp1\2.JPG
STEP 3:  'Right Click' the spot created and 'Implement' it (Create an Implementation).
Description: C:\Documents and Settings\enteg12\Desktop\ppp\104.JPG
Fill in all the details in the 'Create Enhancement Implementation' dialog.
Description: C:\Documents and Settings\enteg12\Desktop\ppp\105.JPG
STEP 4: Now, we need to 'Activate' the enhancement spot. In addition with the Enhancement spot the 'Enhancement Implementation' will get activated.
Description: C:\Documents and Settings\enteg12\Desktop\ppp\106.JPG
STEP 5:  Here we are applying enhancements to a CUSTOM program not a standard program to demonstrate the functionality. So we create a simple program 'YDEV_CODE' (say) it is retrieving records from the database table 'VBAK' (Sales Document Header) and displaying a few records.
Now, if the customer wants to replace the set of logic with his own logic (say) like retrieving records from database table 'VBAP' (Sales Document Item) and then display a few records, he/she will create an enhancement section which goes like,
Create a program YDEV_CODE.  
Description: C:\Documents and Settings\enteg12\Desktop\ppp\107.JPG
OUTPUT
Description: C:\Documents and Settings\enteg12\Desktop\ppp\108.JPG
STEP 6: Right click the area which is appropriate to apply the enhancement
Note - Explicit enhancements though can be placed anywhere in the source code but, not just anywhere except some areas where SAP would allow (program allows).
Description: C:\Documents and Settings\enteg12\Desktop\ppp\109.JPG
àNow, in the 'Create Enhancement Option' fill in the details, here fill the name under 'Enhancement-section' only. Then fill in the Enhancement Spot Implementation Name which we created earlier.
Now we are able to see program lines have Enhancement-Section…End Enhancement-Section.
Note - Make sure that the code which has to be replaced is within the 'ENHANCEMENT-SECTION...' and 'END-ENHANCEMENT-SECTION'.
STEP 7: Now to include the custom code in the program which will replace the original code, enable the 'Enhancement Mode' by clicking on the 'Spiral' button.
Description: http://wiki.sdn.sap.com/wiki/download/attachments/77988719/ENHC_11.JPG?version=1&modificationDate=1234179692881
Place the cursor on the 'Enhancement-section' and navigate to 'Edit' à 'Enhancement Operations' à 'Create Implementation'.
Description: C:\Documents and Settings\enteg12\Desktop\ppp\114.JPG
Fill in the details for the 'Create Enhancement Implementation' dialog. Click on 'Create' button for the 'Select or Create Enhancement Implementation' dialog.
Description: C:\Documents and Settings\enteg12\Desktop\ppp\115.JPG
STEP 8: Now, write the code within the 'ENHANCEMENT' and 'ENDENHANCEMENT' statements as the replacement code.
STEP 9:  Don't forget to 'Activate' the enhancement à  Switch the 'Enhancement' mode OFF and 'Activate' the entire program.
STEP 10: Execute the transaction/program to find out the difference.
Before Enhancement:
Description: C:\Documents and Settings\enteg12\Desktop\ppp\108.JPG  
After Enhancement:
Description: C:\Documents and Settings\enteg12\Desktop\ppp\118.JPG
Summary:
1.     Here we deals with the enhancement of a 'Z' program it is possible to 'CREATE' an 'ENHANCEMENT-SECTION'. But, in case of a 'STANDARD SAP' program there are certain places (provided by SAP) like 'ENHANCEMENT-POINT...' and 'ENHANCEMENT-SECTION...' where we can create implementations based on customer’s business functionality.
2.     There can be only one and only one 'ACTIVE' implementation for an 'ENHANCEMENT-SECTION'.
Source Code:
*&---------------------------------------------------------------------*
*& Report  YDEV_CODE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*


REPORT  YDEV_CODE.
TABLES : VBAK, VBAP.
DATA : IT_VBAK TYPE STANDARD TABLE OF VBAK INITIAL SIZE 0,
      WA_VBAK TYPE VBAK,
      IT_VBAP TYPE STANDARD TABLE OF VBAP INITIAL SIZE 0,
      WA_VBAP TYPE VBAP.


INITIALIZATION.
 REFRESH : IT_VBAK,
           IT_VBAP.
 CLEAR : WA_VBAK,
         WA_VBAP.


START-OF-SELECTION.
ENHANCEMENT-SECTION YDEV_ENHANCE_SECTION SPOTS YDEV_IMPLEMENT_SPOT .
SELECT *
   FROM VBAP
   INTO TABLE IT_VBAP[]
   UP TO 15 ROWS.


 WRITE: /02 'Sales Document',
         20 'Date',
         40 'Time',
         65 'Name of Person'.
ULINE .
 IF IT_VBAP[] IS NOT INITIAL.
   LOOP AT IT_VBAP INTO WA_VBAP.
     WRITE: /02 WA_VBAP-VBELN,
             20 WA_VBAP-POSNR,
             40 WA_VBAP-MATNR,
             65 WA_VBAP-MATWA.
   ENDLOOP.
 ENDIF.
END-ENHANCEMENT-SECTION.
*$*$-Start: YDEV_ENHANCE_SECTION----------------------------------------------------------------$*$*
ENHANCEMENT 1  YDEV_IMPLEMENT_ENHC_SECTION.    "active version
SELECT *
   FROM VBAP
   INTO TABLE IT_VBAP[]
   UP TO 10 ROWS.


 WRITE: /02 'Sales Document',
         20 'Sales Item',
         40 'Material Number',
         65 'Material entered'.
ULINE .
 IF IT_VBAP[] IS NOT INITIAL.
   LOOP AT IT_VBAP INTO WA_VBAP.
     WRITE: /02 WA_VBAP-VBELN,
             20 WA_VBAP-POSNR,
             40 WA_VBAP-MATNR,
             65 WA_VBAP-MATWA.
   ENDLOOP.
 ENDIF.
ENDENHANCEMENT.
*$*$-End:   YDEV_ENHANCE_SECTION----------------------------------------------------------------$*$*



SAP giới thiệu mã hỗ trợ AI trong ngôn ngữ ABAP riêng của mình

SAP đã ra mắt một loạt tính năng mã hỗ trợ AI trong môi trường phát triển ứng dụng dựa trên đám mây của mình, đồng thời tham gia vào danh sá...