Showing posts with label pop-window. Show all posts
Showing posts with label pop-window. Show all posts

Friday, November 23, 2007

sap abap program for Using Function Modules F4_FILENAME

This is Kalidas, working as a Technical Consultant.

Using F4_FILENAME function module we can port data into flatfile. This is material related details.

Try the below code.

*&---------------------------------------------------------------------*
*& Report ZFILENAME_TEST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZFILENAME_TEST.
TABLES : MARA.

*************************INTERNAL TABLE DECLARATION*****************
TYPES : BEGIN OF ITAB,
MATNR TYPE MARA-MATNR,
MEINS TYPE MARA-MEINS,
ERNAM LIKE MARA-ERNAM,
AENAM LIKE MARA-AENAM,
MTART LIKE MARA-MTART,
END OF ITAB.

DATA : IG_ITAB type ITAB OCCURS 0.
DATA : V_FILE TYPE STRING.
DATA : T_FILE TYPE RLGRAP-FILENAME.


***********************RETRIVE DATA FROM DATABASE*******************
break sgopal.
SELECT
MATNR
MEINS ERNAM AENAM MTART FROM MARA
INTO CORRESPONDING FIELDS OF TABLE
IG_ITAB
up to 10 rows.


*****************CALLING FUNCTION MODULES**************************
CALL FUNCTION 'F4_FILENAME' "PASS THE FILE NAME AS U NEED.
EXPORTING
* PROGRAM_NAME = SYST-CPROG
* DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'T_FILE'
IMPORTING
FILE_NAME = T_FILE.

V_FILE = T_FILE. "STRING CONVERSION


***************CALLING GUI DOWNLOAD TO EXTRACT*********************
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
* BIN_FILESIZE =
filename = V_FILE
FILETYPE = 'ASC'
* APPEND = ' '
WRITE_FIELD_SEPARATOR = 'X'
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* IMPORTING
* FILELENGTH =
tables
data_tab = IG_ITAB
* FIELDNAMES =
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.


OUT WHICH I GOT :

'FILENAME.XLS'.

24 EE RTAMANAMU FGTR
31 EA AMUKHERJEE MMOHAN FERT
41 EA NMISHRA LCARAG HALB
42 EA NMISHRA HALB
44 KG GKV ROH
61 EA MAHMMED ZFER
62 EA MAHMMED ZFER
63 EA MAHMMED ZFER
71 EA MAHMMED NKUMAR ZFER
93 EA RAMAMOHAN_C RAMAMOHAN_C ROH

abp program for How to Restrict the Select Options

This report is describes how to restrict the select options.

REPORT selectoptionsrestrict.
* Include type pool SSCR
TYPE-POOLS sscr.
TABLES :
marc.
* defining the selection-screen
select-options :
s_matnr for marc-matnr,
s_werks for marc-werks.
* Define the object to be passed to the RESTRICTION parameter
DATA restrict TYPE sscr_restrict.
* Auxiliary objects for filling RESTRICT
DATA : optlist TYPE sscr_opt_list,
ass type sscr_ass.
INITIALIZATION.
* Restricting the MATNR selection to only EQ and 'BT'.
optlist-name = 'OBJECTKEY1'.
optlist-options-eq = 'X'.
optlist-options-bt = 'X'.
APPEND optlist TO restrict-opt_list_tab.
ass-kind = 'S'.
ass-name = 'S_MATNR'.
ass-sg_main = 'I'.
ass-sg_addy = space.
ass-op_main = 'OBJECTKEY1'.
APPEND ass TO restrict-ass_tab.
* Restricting the WERKS selection to CP, GE, LT, NE.
optlist-name = 'OBJECTKEY2'.
optlist-options-cp = 'X'.
optlist-options-ge = 'X'.
optlist-options-lt = 'X'.
optlist-options-ne = 'X'.
APPEND optlist TO restrict-opt_list_tab.
ass-kind = 'S'.
ass-name = 'S_WERKS'.
ass-sg_main = 'I'.
ass-sg_addy = space.
ass-op_main = 'OBJECTKEY2'.
APPEND ass TO restrict-ass_tab.
CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
EXPORTING
restriction = restrict
EXCEPTIONS
&nbs! p; TOO_LATE = 1
REPEATED = 2
SELOPT_WITHOUT_OPTIONS = 3
SELOPT_WITHOUT_SIGNS = 4
INVALID_SIGN = 5
EMPTY_OPTION_LIST = 6
INVALID_KIND = 7
REPEATED_KIND_A = 8
OTHERS = 9
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

sap abap program for Function Module for Encryption and Decryption

Any function module which can be used for encryption or decryption of any particular field?

Use the following FM to encrypt

CALL FUNCTION 'FIEB_PASSWORD_ENCRYPT'

Use the following FM to decrypt

CALL FUNCTION 'FIEB_PASSWORD_DECRYPT'

By these FM you can encrypt & decrypt any fields of the Program.

Two more things:
1. You can't use these FM to decode user passwords.

2. Although their import parameters are case sensitive, when you test them from se37, the import parameters are converted to uppercase (thus, it may seem that they aren't working). A suggestion: encapsulate them in a custom FM that receives a string to be encrytped/decrypted and a parameter that says if you want to encrypt or decrypt and call this fm from your program. Test them very carefully, because once the string has been encrypted the decryption side is the only way to get it back.

function zsecurtext.
*"----------------------------------------------------------------------
*"*"Interfase local
*" IMPORTING
*" REFERENCE(INTEXT) TYPE FIEB_DECRYPTED_PASSWD OPTIONAL
*" REFERENCE(ENCRYPT) TYPE C OPTIONAL
*" EXPORTING
*" REFERENCE(OUTTEXT) TYPE FIEB_DECRYPTED_PASSWD
*"----------------------------------------------------------------------
** NOTE: This code doesn't work if run from se37. You should
** encrypt
if encrypt = 'X'.
call function 'FIEB_PASSWORD_ENCRYPT'
exporting
im_decrypted_password = intext
importing
ex_encrypted_password = outtext.
else.
******** Decrypting *******************
call function 'FIEB_PASSWORD_DECRYPT'
exporting
im_encrypted_password = intext
importing
ex_decrypted_password = outtext.
endif.

endfunction.

Blog Archive