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

Share this link with your friends

http://www.rebtel.com/u/15163104576

For every friend who signs up using this link and makes a payment, we'll give you 8 €!


Wednesday, September 22, 2010

F4 for files on presentation or Application Server

DATA: l_true TYPE btch0000-char1.
DATA: v_file TYPE string,
l_path TYPE dxlpath,
l_abend_flag TYPE dxxabend,
file TYPE filename,
flag1 TYPE c.
DATA: it_fieldvalues TYPE STANDARD TABLE OF dynpread,
wa_fieldvalues TYPE dynpread.
*-----------------------------------------------------------------------------
*-- SELECTION- SCREEN
*-----------------------------------------------------------------------------
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_file(120) LOWER CASE OBLIGATORY.
PARAMETERS: p_appl RADIOBUTTON GROUP g1,
p_pres RADIOBUTTON GROUP g1.
SELECTION-SCREEN END OF BLOCK b1.
*-----------------------------------------------------------------------------
*-- AT SELECTION- SCREEN ( F4 functionality )
*-----------------------------------------------------------------------------
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM f4_file_name.
*-----------------------------------------------------------------------------
*-- START-OF-SELECTION.
*-----------------------------------------------------------------------------
START-OF-SELECTION.
IF p_appl = 'X'.
PERFORM validate_server_file.
ELSE.
PERFORM validate_presentation_server.
ENDIF.
*-----------------------------------------------------------------------------
*-- END-OF-SELECTION
*-----------------------------------------------------------------------------
END-OF-SELECTION.
IF flag1 = 'X'.
MESSAGE s777(hk) WITH 'File doesn''t exist'.
CLEAR flag1.
ENDIF.
*&---------------------------------------------------------------------*
*& Form validate_server_file
*&---------------------------------------------------------------------*
FORM validate_server_file.
DATA: l_file TYPE tpfht-pffile.
CLEAR l_file.
l_file = p_file.
CALL FUNCTION 'PFL_CHECK_OS_FILE_EXISTENCE'
EXPORTING
fully_qualified_filename = l_file
IMPORTING
file_exists = l_true.
IF l_true = space.
flag1 = 'X'.
STOP.
ENDIF.
ENDFORM. " validate_server_file
*&---------------------------------------------------------------------*
*& Form validate_presentation_server
*&---------------------------------------------------------------------*
FORM validate_presentation_server .
DATA: result,
xfile TYPE string.
xfile = p_file.
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = xfile
RECEIVING
result = result.
IF result NE 'X'.
flag1 = 'X'.
STOP.
ENDIF.
ENDFORM. "validate_presentation_server
*&---------------------------------------------------------------------*
*& Form f4_file_name
*&---------------------------------------------------------------------*
FORM f4_file_name .
wa_fieldvalues-fieldname = 'P_PRES'.
APPEND wa_fieldvalues TO it_fieldvalues.
CLEAR wa_fieldvalues.
wa_fieldvalues-fieldname = 'P_APPL'.
APPEND wa_fieldvalues TO it_fieldvalues.
CLEAR wa_fieldvalues.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
TABLES
dynpfields = it_fieldvalues
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
invalid_parameter = 7
undefind_error = 8
double_conversion = 9
stepl_not_found = 10
OTHERS = 11.
READ TABLE it_fieldvalues INTO wa_fieldvalues WITH KEY fieldname = 'P_APPL'.
IF wa_fieldvalues-fieldvalue = 'X'.
PERFORM get_f4_application.
ELSE.
PERFORM get_f4_presentation.
ENDIF.
ENDFORM. " f4_file_name
*&---------------------------------------------------------------------*
*& Form get_f4_presentation
*&---------------------------------------------------------------------*
FORM get_f4_presentation .
*-- F4 functionality for file name on Presentation Server
DATA: l_file TYPE string.
CALL METHOD cl_salv_test_data=>select_file
IMPORTING
filename = l_file.
p_file = l_file.
ENDFORM. " get_f4_presentation
*&---------------------------------------------------------------------*
*& Form get_f4_application
*&---------------------------------------------------------------------*
form get_f4_application .
*-- F4 functionality for filename on Application Server
CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
EXPORTING
i_location_flag = 'A'
i_server = ' '
i_path = '/secure_data/data_mig/dev'
IMPORTING
o_path = l_path
abend_flag = l_abend_flag
EXCEPTIONS
communication_failure = 1
system_failure = 2
rfc_error = 3.
IF sy-subrc EQ 0.
p_file = l_path.
ENDIF.
IF l_abend_flag = 'X'.
EXIT.
ENDIF.
endform. " get_f4_application

No comments: