Abap Creating a workable button on the selection screen
2:29 AM
*&---------------------------------------------------------------------*
*& Report Y_MARK_TEST_BUTTON
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT Y_MARK_TEST_BUTTON.
TABLES sscrfields.
DATA: ld_filename TYPE string,
ld_path TYPE string,
ld_fullpath TYPE string,
ld_result TYPE i,
gd_file TYPE c.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE LIKE RLGRAP-FILENAME default 'C:\EMAIL_RESULT.XLS'.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN PUSHBUTTON (20) dl_excel USER-COMMAND dl_excel. "button!
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B1.
* At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
* Display save dialog window
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
* window_title = ' '
default_extension = 'XLS'
default_file_name = 'EMAIL_RESULT'
initial_directory = 'C:\'
CHANGING
filename = ld_filename
path = ld_path
fullpath = ld_fullpath
user_action = ld_result.
p_file = ld_fullpath.
AT SELECTION-SCREEN OUTPUT.
MOVE 'Download' TO dl_excel. "giving the button label
AT SELECTION-SCREEN.
case sy-ucomm.
when 'DL_EXCEL'.
"DO WHAT EVER YOU LIKE
endcase.
*& Report Y_MARK_TEST_BUTTON
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT Y_MARK_TEST_BUTTON.
TABLES sscrfields.
DATA: ld_filename TYPE string,
ld_path TYPE string,
ld_fullpath TYPE string,
ld_result TYPE i,
gd_file TYPE c.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE LIKE RLGRAP-FILENAME default 'C:\EMAIL_RESULT.XLS'.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN PUSHBUTTON (20) dl_excel USER-COMMAND dl_excel. "button!
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B1.
* At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
* Display save dialog window
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
* window_title = ' '
default_extension = 'XLS'
default_file_name = 'EMAIL_RESULT'
initial_directory = 'C:\'
CHANGING
filename = ld_filename
path = ld_path
fullpath = ld_fullpath
user_action = ld_result.
p_file = ld_fullpath.
AT SELECTION-SCREEN OUTPUT.
MOVE 'Download' TO dl_excel. "giving the button label
AT SELECTION-SCREEN.
case sy-ucomm.
when 'DL_EXCEL'.
"DO WHAT EVER YOU LIKE
endcase.
abap : How to save a file using a dialog box
1:31 AM*Selecting a file to save too, plus inserting default file extension .xls
tables rlgrap.
DATA: ld_filename TYPE string,
ld_path TYPE string,
ld_fullpath TYPE string,
ld_result TYPE i,
gd_file TYPE c.
selection-screen begin of block m with frame.
PARAMETERS: p_file TYPE rlgrap-filename.
selection-screen end of block m.
* At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
* Display save dialog window
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
* window_title = ' '
default_extension = 'XLS'
default_file_name = 'accountsdata'
initial_directory = 'c:\temp\'
CHANGING
filename = ld_filename
path = ld_path
fullpath = ld_fullpath
user_action = ld_result.
p_file = ld_fullpath.
source : http://www.sapdev.co.uk/file/file_objsave.htm
Abap how to read a comma delimited data into internal table
1:23 AMdon't know about gui_upload, the way we do it is:
declare an internal table like:
data: begin of i_rec occurs 0,
filler(200),
end of i_rec.
data: begin of itab occurs 0,
field1,
field2,
...
end of itab.
Itab is the table you want to fill, i_rec is just a temporary intermediary table.
data: sep_field(1) value ','.
that's your separator (comma or something else).
First call the function GUI_UPLOAD and fill table i_rec with the data in your file.
then:
loop at i_rec.
split i_rec-filler at sep_field into itab-field1 itab-field2 ...
append itab.
clear itab.
endloop.
this should do the trick for as far as I know.
good luck,
ioana
source
http://sap.ittoolbox.com/groups/technical-functional/sap-dev/comma-delimited-file-to-internal-table-151418
declare an internal table like:
data: begin of i_rec occurs 0,
filler(200),
end of i_rec.
data: begin of itab occurs 0,
field1,
field2,
...
end of itab.
Itab is the table you want to fill, i_rec is just a temporary intermediary table.
data: sep_field(1) value ','.
that's your separator (comma or something else).
First call the function GUI_UPLOAD and fill table i_rec with the data in your file.
then:
loop at i_rec.
split i_rec-filler at sep_field into itab-field1 itab-field2 ...
append itab.
clear itab.
endloop.
this should do the trick for as far as I know.
good luck,
ioana
source
http://sap.ittoolbox.com/groups/technical-functional/sap-dev/comma-delimited-file-to-internal-table-151418
Abap how to create an excel file sample
11:05 PM
REPORT ZEX_DATATOEXCEL .
Parameters: P_file like RLGRAP-FILENAME.
data : begin of int_head occurs 0,
Filed1(20) type c, " Header Data
end of int_head.
data : begin of int_data occurs 0,
Field1(20) type c, " Data
Field2(20) type c,
Field3(20) type c,
Field4(20) type c,
end of int_data.
int_head-Filed1 = 'Sales Ord'.
APPEND int_head.
CLEAR int_head.
int_head-Filed1 = 'Sold-to-Party'.
APPEND int_head.
CLEAR int_head.
int_head-Filed1 = 'Purchase Ord'.
APPEND int_head.
CLEAR int_head.
int_head-Filed1 = 'Ship-to-Party'.
APPEND int_head.
CLEAR int_head.
int_data-field1 = '1JOHN'.
int_data-field2 = '2TOM'.
int_data-field3 = '3BRAD'.
int_data-field4 = '4PETER'.
Append int_data.
Clear int_data.
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = p_file " path offile where u need to download
* CREATE_PIVOT = 0
* DATA_SHEET_NAME = ' '
* PIVOT_SHEET_NAME = ' '
* PASSWORD = ' '
* PASSWORD_OPTION = 0
TABLES
* PIVOT_FIELD_TAB =
data_tab = int_data "internal table with data
fieldnames = int_head "internal table with header
EXCEPTIONS
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_filename = 6
invalid_pivot_fields = 7
download_problem = 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.
source
http://abaplovers.blogspot.com/2008/05/abap-internal-table-to-excel-sheet.html
Parameters: P_file like RLGRAP-FILENAME.
data : begin of int_head occurs 0,
Filed1(20) type c, " Header Data
end of int_head.
data : begin of int_data occurs 0,
Field1(20) type c, " Data
Field2(20) type c,
Field3(20) type c,
Field4(20) type c,
end of int_data.
int_head-Filed1 = 'Sales Ord'.
APPEND int_head.
CLEAR int_head.
int_head-Filed1 = 'Sold-to-Party'.
APPEND int_head.
CLEAR int_head.
int_head-Filed1 = 'Purchase Ord'.
APPEND int_head.
CLEAR int_head.
int_head-Filed1 = 'Ship-to-Party'.
APPEND int_head.
CLEAR int_head.
int_data-field1 = '1JOHN'.
int_data-field2 = '2TOM'.
int_data-field3 = '3BRAD'.
int_data-field4 = '4PETER'.
Append int_data.
Clear int_data.
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = p_file " path offile where u need to download
* CREATE_PIVOT = 0
* DATA_SHEET_NAME = ' '
* PIVOT_SHEET_NAME = ' '
* PASSWORD = ' '
* PASSWORD_OPTION = 0
TABLES
* PIVOT_FIELD_TAB =
data_tab = int_data "internal table with data
fieldnames = int_head "internal table with header
EXCEPTIONS
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_filename = 6
invalid_pivot_fields = 7
download_problem = 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.
source
http://abaplovers.blogspot.com/2008/05/abap-internal-table-to-excel-sheet.html
How to debug universal worklist, approval pending list, approval program.
7:44 PM
Knowledge sharing by Mohd Khairil Bin Markom my colleague :)
Recent workflow debugging for supervisor
How do we debug a program which has been configured in swfvisu?
Applicant we can easily debugged from the
Transaction code = SE80
But as the work flow comes into the picture the data/application is routed to the supervisor
STEP 1
Still using the transaction code SE80.
Put a debugmode under
- Component Controller -> Method -> wdoinit (place any break point there tips: best at the first line)
- Test run first! Let it stay in the debug mode and then proceed to STEP 2
STEP 2
Log into the portal
1.CLICK on the work ( universal worklist - the place where you can see the approval's pending list)
2.CLICK on the document that is pending
STEP 3
Once step 1 and step 2 is achieved.
You can start you exploration to debug which ever error you can find in the approval webdynpro
Recent workflow debugging for supervisor
How do we debug a program which has been configured in swfvisu?
Applicant we can easily debugged from the
Transaction code = SE80
But as the work flow comes into the picture the data/application is routed to the supervisor
STEP 1
Still using the transaction code SE80.
Put a debugmode under
- Component Controller -> Method -> wdoinit (place any break point there tips: best at the first line)
- Test run first! Let it stay in the debug mode and then proceed to STEP 2
STEP 2
Log into the portal
1.CLICK on the work ( universal worklist - the place where you can see the approval's pending list)
2.CLICK on the document that is pending
STEP 3
Once step 1 and step 2 is achieved.
You can start you exploration to debug which ever error you can find in the approval webdynpro
Sample ALV Grid program using the function module REUSE_ALV_GRID_DISPLAY
7:40 PMSample ALV Grid program using the function module REUSE_ALV_GRID_DISPLAY
By Vikram Chellappa, Mouri Tech Solutions
*&---------------------------------------------------------------------* *& Report ZALV_REPORT_SFLIGHT *& *&---------------------------------------------------------------------* * Published at SAPTechnical.COM *&---------------------------------------------------------------------*REPORT ZALV_REPORT_SFLIGHT. TABLES : SFLIGHT. TYPE-POOLS : SLIS.**INTERNAL TABLE DECLARTION DATA : WA_SFLIGHT TYPE SFLIGHT, IT_SFLIGHT TYPE TABLE OF SFLIGHT.**DATA DECLARTION DATA: FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE, GD_LAYOUT TYPE SLIS_LAYOUT_ALV, GD_REPID LIKE SY-REPID, G_SAVE TYPE C VALUE 'X', G_VARIANT TYPE DISVARIANT, GX_VARIANT TYPE DISVARIANT, G_EXIT TYPE C, ISPFLI TYPE TABLE OF SPFLI.* To understand the importance of the following parameter, click here. **SELECTION SCREEN DETAILS SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002 . PARAMETERS: VARIANT LIKE DISVARIANT-VARIANT. SELECTION-SCREEN END OF BLOCK B1. **GETTING DEFAULT VARIANT INITIALIZATION. GX_VARIANT-REPORT = SY-REPID. CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET' EXPORTING I_SAVE = G_SAVE CHANGING CS_VARIANT = GX_VARIANT EXCEPTIONS NOT_FOUND = 2. IF SY-SUBRC = 0. VARIANT = GX_VARIANT-VARIANT. ENDIF.**PERFORM DECLARATIONS START-OF-SELECTION. PERFORM DATA_RETRIVEL. PERFORM BUILD_FIELDCATALOG. PERFORM DISPLAY_ALV_REPORT. *&---------------------------------------------------------------------* *& Form BUILD_FIELDCATALOG *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM BUILD_FIELDCATALOG . FIELDCATALOG-FIELDNAME = 'CARRID'. FIELDCATALOG-SELTEXT_M = 'Airline Code'. FIELDCATALOG-COL_POS = 0. APPEND FIELDCATALOG TO FIELDCATALOG. CLEAR FIELDCATALOG. FIELDCATALOG-FIELDNAME = 'CONNID'. FIELDCATALOG-SELTEXT_M = 'Flight Connection Number'. FIELDCATALOG-COL_POS = 1. APPEND FIELDCATALOG TO FIELDCATALOG. CLEAR FIELDCATALOG. FIELDCATALOG-FIELDNAME = 'FLDATE'. FIELDCATALOG-SELTEXT_M = 'Flight date'. FIELDCATALOG-COL_POS = 2. APPEND FIELDCATALOG TO FIELDCATALOG. CLEAR FIELDCATALOG. FIELDCATALOG-FIELDNAME = 'PRICE'. FIELDCATALOG-SELTEXT_M = 'Airfare'. FIELDCATALOG-COL_POS = 3. FIELDCATALOG-OUTPUTLEN = 20. APPEND FIELDCATALOG TO FIELDCATALOG. CLEAR FIELDCATALOG. ENDFORM. " BUILD_FIELDCATALOG *&---------------------------------------------------------------------* *& Form DISPLAY_ALV_REPORT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM DISPLAY_ALV_REPORT . GD_REPID = SY-REPID. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING I_CALLBACK_PROGRAM = GD_REPID I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE' "see FORM I_CALLBACK_USER_COMMAND = 'USER_COMMAND' IT_FIELDCAT = FIELDCATALOG[] I_SAVE = 'X' IS_VARIANT = G_VARIANT TABLES T_OUTTAB = IT_SFLIGHT EXCEPTIONS PROGRAM_ERROR = 1 OTHERS = 2. 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. "DISPLAY_ALV_REPORT" DISPLAY_ALV_REPORT *&---------------------------------------------------------------------* *& Form DATA_RETRIVEL *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM DATA_RETRIVEL . SELECT * FROM SFLIGHT INTO TABLE IT_SFLIGHT. ENDFORM. " DATA_RETRIVEL*-------------------------------------------------------------------* * Form TOP-OF-PAGE * *-------------------------------------------------------------------* * ALV Report Header * *-------------------------------------------------------------------* FORM TOP-OF-PAGE. *ALV Header declarations DATA: T_HEADER TYPE SLIS_T_LISTHEADER, WA_HEADER TYPE SLIS_LISTHEADER, T_LINE LIKE WA_HEADER-INFO, LD_LINES TYPE I, LD_LINESC(10) TYPE C.* Title WA_HEADER-TYP = 'H'. WA_HEADER-INFO = 'SFLIGHT Table Report'. APPEND WA_HEADER TO T_HEADER. CLEAR WA_HEADER.* Date WA_HEADER-TYP = 'S'. WA_HEADER-KEY = 'Date: '. CONCATENATE SY-DATUM+6(2) '.' SY-DATUM+4(2) '.' SY-DATUM(4) INTO WA_HEADER-INFO. "todays date APPEND WA_HEADER TO T_HEADER. CLEAR: WA_HEADER. CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' EXPORTING IT_LIST_COMMENTARY = T_HEADER. ENDFORM. "top-of-page
SOURCEhttp://www.saptechnical.com/Tutorials/ALV/SampleALVGridProgram.htm
Abap: Country Grouping
7:38 PMDATA P_MOLGA TYPE MOLGA.
CALL FUNCTION 'HR_COUNTRYGROUPING_GET'
EXPORTING
PERNR = WD_COMP_CONTROLLER->PERNR
* TCLAS = 'A'
* BEGDA = '18000101'
* ENDDA = '99991231'
* WERKS =
IMPORTING
MOLGA = P_MOLGA
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
source