Welcome To My BLOG
This site is to give a brief idea for the abap learners who are looking for some real time programs .It consists of collection of programs from my side . I hope these programs are very much used for all of the learners. Please check the links for any information in ABAP.
Please vote for my Blog. And please input me on this mail addrssess.Email me
Please vote for my Blog. And please input me on this mail addrssess.Email me
Share this link with your friends
http://www.rebtel.com/u/15163104576
Wednesday, May 11, 2011
Formatting SAPScript / SMARTFORMS in SAP
There are few formatting options available in SAP for text formatting in SAPScript as well as Smartforms.
Smartforms Formatting
Following are the few useful formatting options:
Offset:
N left-most characters of the symbol value will not be displayed.
If symbol has the value 123456789, the following will be displayed:
&symbol& -> 123456789
&symbol+3& -> 456789
&symbol+7& -> 89
&symbol+12& ->
&symbol+0& -> 123456789
Output Length
To define how many character positions should be copied from the value.
If symbol has the value 123456789.
&symbol(3)& -> 123
&symbol(7)& -> 1234567
The SYST-UNAME field contains the logon name of a user called Einstein. The
Dictionary entry for this field contains an output length of 12.
&SYST-UNAME&… -> Einstein…
&SYST-UNAME(9)&… -> Einstein …
&SYST-UNAME(*)&… -> Einstein …
Omitting the Leading Sign
The S option can be used to ensure that the value is formatted without the sign.
The ITCDP-TDULPOS field contains the value -100.00. The ABAP/4 Dictionary
definition for this field includes a leading sign.
&ITCDP-TDULPOS& -> 100.00-
&ITCDP-TDULPOS(S)& -> 100.00
Leading Sign to the Left
This option enables you to specify that the leading sign should be placed to the left of the number.
&ITCDP-TDULPOS& -> 100.00-
&ITCDP-TDULPOS(<)& -> -100.00
Leading Sign to the Right
If you used the SET SIGN LEFT control command to specify that the leading sign should be output before the value, this specification can be overridden for individual symbols to enable these to be output with the leading sign to the right.
Syntax:
&symbol(>)&
Omitting Leading Zeros
Certain symbol values are output with leading zeros. If you wish to suppress these, you may do so with the Z option.
Assuming the current date is 1.1.1994, &DAY& -> 01
&DAY(Z)& -> 1
Space Compression
The C option has the effect of replacing each string of space characters with a single space and shifting the ’words’ to the left as necessary to close up the gaps.
Assuming ‘ Albert Einstein ‘ is the symbol value,
&symbol& -> Albert Einstein
&symbol(C)& -> Albert Einstein
Number of Decimal Places
A program symbol of one of the data types DEC, QUAN and FLTP can contain decimal place data. This option is used to override the Dictionary definition for the number of decimal places for the formatting of this symbol value.
The EKPO-MENGE field contains the value 1234.56. The Dictionary definition specifies 3 decimal places and an output length of 17.
&EKPO-MENGE& -> 1,234.560
&EKPO-MENGE(.1) -> 1,234.6
&EKPO-MENGE&(.4) -> 1,234.5600
&EKPO-MENGE&(.0) -> 1,235
Specifying an Exponent for Floating Point Numbers
The way that a floating point number is formatted depends on whether an exponent is specified.
PLMK-SOLLWERT field is assumed to have the value
123456.78 and to be of data type FLTP.
&PLMK-SOLLWERT& -> +1.23456780000000E+05
&PLMK-SOLLWERT(E3)& -> +123.456780000000E+03
&PLMK-SOLLWERT(E6)& -> +0.12345678000000E+06
&PLMK-SOLLWERT(E0)& -> +123456.780000000
&PLMK-SOLLWERT(E)& -> +123456.780000000
Right-Justified Output
Right-justified formatting can be specified with the R option. This option has to be used in conjunction with an output length specification. If symbol has the value 1234.
&symbol& -> 1234
&symbol(8R) -> 1234
Fill Characters
Leading spaces in a value can be replaced with a fill character.
The figure for customer sales in the KNA1-UMSAT field is $700. The Dictionary description of the field specifies an output length 8.
&KNA1-UMSAT& -> 700.00
&KNA1-UMSAT(F*)& -> **700.00
&KNA1-UMSAT(F0)& -> 00700.00
Suppress Output of Initial Value
The I option can be used to suppress the output of symbols which still contain their initial value.
Assuming KNA1-UMSAT contains the value 0 and the currency is DEM.
&KNA1-UMSAT& -> 0,00
&KNA1-UMSAT(I)& ->
If the field contains an amount other than 0, this value will be output in the normal way.
&KNA1-UMSAT& -> 700,00
&KNA1-UMSAT(I)& -> 700,00
Ignore Conversion Routines
SAPscript conversion routines specified in the Dictionary are automatically recognized and used when program symbols are being formatted. Using the K option can prevent these conversions.
Date Mask
The formatting for date fields can be defined with the SAPscript SET DATE MASK command. Executing this command causes all subsequent date fields to be output using the specified formatting.
/: SET DATE MASK = ‘date_mask’
The following templates may be used in the date mask:
DD day (two digits)
DDD name of day (abbreviated)
DDDD name of day (written out in full)
MM month (two digits)
MMM name of month (abbreviated)
MMMM name of month (written out in full)
YY year (two digits)
YYYY year (four digits)
LD day (formatted as for the L option)
LM month (formatted as for the L option)
LY year (formatted as for the L option)
Time Mask
You can use the SAPscript SET TIME MASK command to format time fields in a way that differs from the standard setting.
Assuming the current time is 10:08:12.
&TIME& -> 10:08:12
/: SET TIME MASK = ‘HH:MM’
&TIME& -> 10:08
/: SET TIME MASK = ‘HH hours MM minutes’
&TIME& -> 10 hours 08 minutes
&TIME(Z)& -> 10 hours 8 minutes
Other Standard Outputs:
&DAY&, &MONTH&, &YEAR&, &HOURS&, &MINUTES&, &SECONDS&, &DATE&,
&TIME&, &PAGE&, &NEXTPAGE&.
Tuesday, April 19, 2011
Monday, April 18, 2011
Upload Images in SE78 using SE38
REPORT ZINHP_UPLOAD_SIGNATURE .
Description..............: UPLOAD IMAGES .
**********************************************************************
TYPE-POOLS TRUXS.
DATA L_V_RAW TYPE TRUXS_T_TEXT_DATA.
*===Data declaration
DATA : " L_filname type rlgrap-filename,
" l_name TYPE stxbitmaps-tdname,
L_OBJECT TYPE STXBITMAPS-TDOBJECT,
L_ID TYPE STXBITMAPS-TDID,
L_BTYPE TYPE STXBITMAPS-TDBTYPE,
L_FORMAT TYPE DAPPL,
" L_title like bapisignat-prop_value,
L_RESIDENT TYPE STXBITMAPS-RESIDENT,
L_AUTOHEIGHT TYPE STXBITMAPS-AUTOHEIGHT,
* l_bmcomp TYPE stxbitmaps-bmcomp,
L_DOCID TYPE STXBITMAPS-DOCID,
L_RESOLUTION TYPE STXBITMAPS-RESOLUTION.
*=== Internal table
DATA: BEGIN OF G_TY_UPLOAD OCCURS 0,
F_NAME LIKE RLGRAP-FILENAME,
T_NAME LIKE STXBITMAPS-TDNAME,
DESC LIKE BAPISIGNAT-PROP_VALUE,
END OF G_TY_UPLOAD.
*=== Internal table for output
DATA G_T_FINAL LIKE TABLE OF G_TY_UPLOAD WITH HEADER LINE.
*===selection screen for input
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE HEADER.
PARAMETERS : L_FILNAM LIKE RLGRAP-FILENAME.
* l_name like stxbitmaps-tdname,
* l_title LIKE bapisignat-prop_value.
SELECTION-SCREEN: END OF BLOCK B1.
*===initilization
INITIALIZATION.
MOVE TEXT-002 TO HEADER.
*===selection screen for F4 help
AT SELECTION-SCREEN ON VALUE-REQUEST FOR L_FILNAM.
*===F4 help for getting file name
PERFORM F4_HELP.
*===start-of-selection
START-OF-SELECTION.
*=== To convert XLS to SAP
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR = 'X'
* I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = L_V_RAW
I_FILENAME = L_FILNAM
TABLES
I_TAB_CONVERTED_DATA = G_T_FINAL.
* EXCEPTIONS
* CONVERSION_FAILED = 1
* OTHERS = 2
*===Passing values to upload images in SE78
LOOP AT G_T_FINAL.
L_OBJECT = 'GRAPHICS'.
L_ID = 'BMAP'.
L_BTYPE = 'BCOL'. " To set Color or B/w
L_FORMAT = 'BMP'. " File format always " BMP".
L_AUTOHEIGHT = 'X'.
* l_name = g_t_final-desc."l_title.
*=== Importing bitmap images to SAP
PERFORM IMPORT_BITMAP_BDS IN PROGRAM SAPLSTXBITMAPS
USING G_T_FINAL-F_NAME
G_T_FINAL-T_NAME
L_OBJECT
L_ID
L_BTYPE
L_FORMAT
G_T_FINAL-DESC
L_RESIDENT
L_AUTOHEIGHT
* l_bmcomp
CHANGING L_DOCID
L_RESOLUTION.
*==Clear internal tables
CLEAR : G_T_FINAL, L_DOCID , L_DOCID, L_RESIDENT ,L_RESOLUTION.
ENDLOOP.
*&---------------------------------------------------------------------*
*& Form F4_HELP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM F4_HELP.
DATA : LT_FT TYPE FILETABLE.
DATA : LS_FT TYPE FILE_TABLE.
DATA : LV_RC TYPE I.
DATA : LV_ACTION TYPE I.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE = 'Filename'
DEFAULT_EXTENSION = 'XLS'
CHANGING
FILE_TABLE = LT_FT
RC = LV_RC
USER_ACTION = LV_ACTION
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
*== if user chooses cancel , do nothing.
IF LV_ACTION = 9.
EXIT.
*== if user chooses Ok , read the filename user choose
ELSEIF LV_ACTION = 0.
READ TABLE LT_FT INTO LS_FT INDEX 1.
IF SY-SUBRC EQ 0.
L_FILNAM = LS_FT-FILENAME.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. "F4_HELP
Description..............: UPLOAD IMAGES .
**********************************************************************
TYPE-POOLS TRUXS.
DATA L_V_RAW TYPE TRUXS_T_TEXT_DATA.
*===Data declaration
DATA : " L_filname type rlgrap-filename,
" l_name TYPE stxbitmaps-tdname,
L_OBJECT TYPE STXBITMAPS-TDOBJECT,
L_ID TYPE STXBITMAPS-TDID,
L_BTYPE TYPE STXBITMAPS-TDBTYPE,
L_FORMAT TYPE DAPPL,
" L_title like bapisignat-prop_value,
L_RESIDENT TYPE STXBITMAPS-RESIDENT,
L_AUTOHEIGHT TYPE STXBITMAPS-AUTOHEIGHT,
* l_bmcomp TYPE stxbitmaps-bmcomp,
L_DOCID TYPE STXBITMAPS-DOCID,
L_RESOLUTION TYPE STXBITMAPS-RESOLUTION.
*=== Internal table
DATA: BEGIN OF G_TY_UPLOAD OCCURS 0,
F_NAME LIKE RLGRAP-FILENAME,
T_NAME LIKE STXBITMAPS-TDNAME,
DESC LIKE BAPISIGNAT-PROP_VALUE,
END OF G_TY_UPLOAD.
*=== Internal table for output
DATA G_T_FINAL LIKE TABLE OF G_TY_UPLOAD WITH HEADER LINE.
*===selection screen for input
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE HEADER.
PARAMETERS : L_FILNAM LIKE RLGRAP-FILENAME.
* l_name like stxbitmaps-tdname,
* l_title LIKE bapisignat-prop_value.
SELECTION-SCREEN: END OF BLOCK B1.
*===initilization
INITIALIZATION.
MOVE TEXT-002 TO HEADER.
*===selection screen for F4 help
AT SELECTION-SCREEN ON VALUE-REQUEST FOR L_FILNAM.
*===F4 help for getting file name
PERFORM F4_HELP.
*===start-of-selection
START-OF-SELECTION.
*=== To convert XLS to SAP
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR = 'X'
* I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = L_V_RAW
I_FILENAME = L_FILNAM
TABLES
I_TAB_CONVERTED_DATA = G_T_FINAL.
* EXCEPTIONS
* CONVERSION_FAILED = 1
* OTHERS = 2
*===Passing values to upload images in SE78
LOOP AT G_T_FINAL.
L_OBJECT = 'GRAPHICS'.
L_ID = 'BMAP'.
L_BTYPE = 'BCOL'. " To set Color or B/w
L_FORMAT = 'BMP'. " File format always " BMP".
L_AUTOHEIGHT = 'X'.
* l_name = g_t_final-desc."l_title.
*=== Importing bitmap images to SAP
PERFORM IMPORT_BITMAP_BDS IN PROGRAM SAPLSTXBITMAPS
USING G_T_FINAL-F_NAME
G_T_FINAL-T_NAME
L_OBJECT
L_ID
L_BTYPE
L_FORMAT
G_T_FINAL-DESC
L_RESIDENT
L_AUTOHEIGHT
* l_bmcomp
CHANGING L_DOCID
L_RESOLUTION.
*==Clear internal tables
CLEAR : G_T_FINAL, L_DOCID , L_DOCID, L_RESIDENT ,L_RESOLUTION.
ENDLOOP.
*&---------------------------------------------------------------------*
*& Form F4_HELP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM F4_HELP.
DATA : LT_FT TYPE FILETABLE.
DATA : LS_FT TYPE FILE_TABLE.
DATA : LV_RC TYPE I.
DATA : LV_ACTION TYPE I.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE = 'Filename'
DEFAULT_EXTENSION = 'XLS'
CHANGING
FILE_TABLE = LT_FT
RC = LV_RC
USER_ACTION = LV_ACTION
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
*== if user chooses cancel , do nothing.
IF LV_ACTION = 9.
EXIT.
*== if user chooses Ok , read the filename user choose
ELSEIF LV_ACTION = 0.
READ TABLE LT_FT INTO LS_FT INDEX 1.
IF SY-SUBRC EQ 0.
L_FILNAM = LS_FT-FILENAME.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. "F4_HELP
Used to limit user commands on selection-screen
* Used to limit user commands on selection-screen
INCLUDE RSDBC1XX.
* Selection Screen
PARAMETERS: P_CHECK TYPE C.
* Events
AT SELECTION-SCREEN OUTPUT.
APPEND 'PRIN' TO CURRENT_SCR-EXCL.
APPEND 'ONLI' TO CURRENT_SCR-EXCL.
INCLUDE RSDBC1XX.
* Selection Screen
PARAMETERS: P_CHECK TYPE C.
* Events
AT SELECTION-SCREEN OUTPUT.
APPEND 'PRIN' TO CURRENT_SCR-EXCL.
APPEND 'ONLI' TO CURRENT_SCR-EXCL.
Sunday, January 2, 2011
Defining Print Parameters In SAP
SAP is using certain print parameters for its print outs. For example to print out Billing, Sales Document, there are parameters to maintain such as the program’s name, the report’s name (SmartForms or SAPscript), The output message type, etc.
For example in VA03, SAP is maintaining several output types to print each transaction, e.g. Billing, Sales, Debit Note, etc.
Now to see what parameters maintained for each output type (Printing Parameters), you can use TCODE V/30.
1. Execute TCODE V/30.
2. Now you can see the output type list for each transaction, click on the “Position” button to search an output type.
3. Enter the Output Type that you want to find and click OK or just press enter.
4. Select the output type and double click on the “Processing Routine” section.
5. On the next screen, you will see the print parameters for the selected output type. E.g. The ABAP program’s name, the SmartForms name, etc.
For example in VA03, SAP is maintaining several output types to print each transaction, e.g. Billing, Sales, Debit Note, etc.
Now to see what parameters maintained for each output type (Printing Parameters), you can use TCODE V/30.
1. Execute TCODE V/30.
2. Now you can see the output type list for each transaction, click on the “Position” button to search an output type.
3. Enter the Output Type that you want to find and click OK or just press enter.
4. Select the output type and double click on the “Processing Routine” section.
5. On the next screen, you will see the print parameters for the selected output type. E.g. The ABAP program’s name, the SmartForms name, etc.
How To Open SAP Transaction Using ABAP Function
In today’s tutorial I want to teach you how to open new SAP transaction using ABAP Function called “CC_CALL_TRANSACTION_NEW_TASK”.
Program Description:
We will be creating a start up program that will call this function and open a new transaction for VL03N, and it will skip the first screen while supplying the delivery order number and display the delivery order screen.
Here’s the ABAP sample source code.
Z_CALL_NEW_TASK.
WRITE:/ ‘This is your main Program ‘.
WRITE:/ ‘You will see a new session program’.
WRITE:/ ‘Opened after this program is active’.
DATA :
lv_skscr(1) TYPE c VALUE ‘X’,
lv_vbeln LIKE LIKP-VBELN VALUE ‘5572000119′,
l_st_prscr TYPE tpara,
l_it_scrprm TYPE TABLE OF tpara.
CLEAR l_st_prscr.
CLEAR l_it_scrprm[].
l_st_prscr-paramid = ‘VL’.
l_st_prscr-partext = lv_vbeln.
APPEND l_st_prscr TO l_it_scrprm.
CALL FUNCTION ‘CC_CALL_TRANSACTION_NEW_TASK’
STARTING NEW TASK ‘VL03N’
DESTINATION ‘NONE’
EXPORTING
transaction = ‘VL03N’
skip_first_screen = ‘X’
TABLES
paramtab = l_it_scrprm
EXCEPTIONS
communication_failure = 97
system_failure = 98
OTHERS = 99.
IF sy-subrc = 0.
” Success
ELSEIF sy-subrc = 97.
” Communication Failure
EXIT.
ELSEIF sy-subrc = 98.
” System Failure
EXIT.
ELSE.
EXIT.
ENDIF.
1. Now Run the program (F8)
2. Below you will see there are 2 programs active, the first one is the ABAP program that is calling the VL03 transaction.
Program Description:
We will be creating a start up program that will call this function and open a new transaction for VL03N, and it will skip the first screen while supplying the delivery order number and display the delivery order screen.
Here’s the ABAP sample source code.
Z_CALL_NEW_TASK.
WRITE:/ ‘This is your main Program ‘.
WRITE:/ ‘You will see a new session program’.
WRITE:/ ‘Opened after this program is active’.
DATA :
lv_skscr(1) TYPE c VALUE ‘X’,
lv_vbeln LIKE LIKP-VBELN VALUE ‘5572000119′,
l_st_prscr TYPE tpara,
l_it_scrprm TYPE TABLE OF tpara.
CLEAR l_st_prscr.
CLEAR l_it_scrprm[].
l_st_prscr-paramid = ‘VL’.
l_st_prscr-partext = lv_vbeln.
APPEND l_st_prscr TO l_it_scrprm.
CALL FUNCTION ‘CC_CALL_TRANSACTION_NEW_TASK’
STARTING NEW TASK ‘VL03N’
DESTINATION ‘NONE’
EXPORTING
transaction = ‘VL03N’
skip_first_screen = ‘X’
TABLES
paramtab = l_it_scrprm
EXCEPTIONS
communication_failure = 97
system_failure = 98
OTHERS = 99.
IF sy-subrc = 0.
” Success
ELSEIF sy-subrc = 97.
” Communication Failure
EXIT.
ELSEIF sy-subrc = 98.
” System Failure
EXIT.
ELSE.
EXIT.
ENDIF.
1. Now Run the program (F8)
2. Below you will see there are 2 programs active, the first one is the ABAP program that is calling the VL03 transaction.
SAP Authorization Object Tables List
Here’s a list of SAP authorization Object tables for your reference.
You can execute TCODE SE11 and see more details of each table, such as column description, field type, etc.
Table Name Description
TOBJ Authorization Objects
TACT Activities which can be Protected
TACTZ Valid Activities for each authorization object
TDDAT Maintenance Areas for tables
TSTC SAP Transaction Codes
TPGP ABAP/4 Authorization groups
USOBT Relation transaction > Authorization Object
USOBX Check table for table USOBT
USOBT_C Relation Transaction > Auth. Object (Customer)
USOBX_C Check table for table USOBT_C
You can execute TCODE SE11 and see more details of each table, such as column description, field type, etc.
Table Name Description
TOBJ Authorization Objects
TACT Activities which can be Protected
TACTZ Valid Activities for each authorization object
TDDAT Maintenance Areas for tables
TSTC SAP Transaction Codes
TPGP ABAP/4 Authorization groups
USOBT Relation transaction > Authorization Object
USOBX Check table for table USOBT
USOBT_C Relation Transaction > Auth. Object (Customer)
USOBX_C Check table for table USOBT_C
Subscribe to:
Posts (Atom)