Problem with Excel button in ALV Grid...URGENT
Hi All,
I have developed a report in ALV Grid. As we all know that by default we get few buttons in ALV Grid, like summation, sorting download, etc.. In that we have one excel button. When i click that excel button the output of the report should give the output in excel sheet. But this is not working.
The report is running fine except the excel button.
Do anyone of u have any idea how to do that?
Its very urgent...
Regards,
Parvez.
Go through the code and Execute it on your system, I think this will do for you.
In this code I used 3 radio buttons in my selection screen:
If u selects the first radio button your out put shows into to the Excel sheet.
If u selects the second radio button your out put shows the in the Editor screen.
If u clicks the third radio button your output shows into the Excel as well as in the Editor.
*& DATA DECLARATION *
TABLES: MARA, "GENERAL MASTER DATA
MARC, "PLANT DATA FOR MATERIAL
MARD, "STORAGE LOCATION DATA FOR MATERIAL
MBEW, "MATERIAL VALUATION
MVKE, "SALES DATA FOR MATERIAL
MAKT, "MATERIAL DESCRIPTION
EKKO, "PURCHASING DOCUMENT HEADER
EKPO, "PURCHASING DOCUMENT ITEM
VBAK, "SALES DOCUMENT HEADER DATA
VBAP. "SALES DOCUMENT ITEM DATA
TYPE-POOLS : SLIS.
DATA: VT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV,
V_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
V_LAYOUT TYPE SLIS_LAYOUT_ALV,
BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
BEGIN OF I_MARA OCCURS 0,
MATNR LIKE MARA-MATNR, "MATERIAL NUMBER
MBRSH LIKE MARA-MBRSH, "INDUSTRY SECTOR
MEINS LIKE MARA-MEINS, "BASE UNIT OF MEASURE
MATKL LIKE MARA-MATKL, "MATERIAL GROUP
END OF I_MARA,
BEGIN OF I_MARC OCCURS 0,
MATNR LIKE MARC-MATNR, "MATERIAL NUMBER
WERKS LIKE MARC-WERKS, "PLANT
LVORM LIKE MARC-LVORM, "FLAG MATERIAL FOR DELETION AT PLANT
"LEVEL
DISPO LIKE MARC-DISPO, "MRP CONTROLLER
END OF I_MARC,
BEGIN OF I_MAKT OCCURS 0,
MATNR LIKE MAKT-MATNR, "MATERIAL NUMBER
MAKTX LIKE MAKT-MAKTX, "MATERIAL DESCRIPTION
SPRAS LIKE MAKT-SPRAS, "LANGUAGE KEY
END OF I_MAKT,
BEGIN OF I_MVKE OCCURS 0,
MATNR LIKE MVKE-MATNR, "MATERIAL NUMBER
VKORG LIKE MVKE-VKORG, "SALES ORGANIZATION
VTWEG LIKE MVKE-VTWEG, "DISTRIBUTION CHANNEL
END OF I_MVKE,
BEGIN OF I_MARD OCCURS 0,
MATNR LIKE MARD-MATNR, "MATERIAL NUMBER
LGORT LIKE MARD-LGORT, "STORAGE LOCATION
LABST LIKE MARD-LABST, "VALUATED STOCK WITH UNRESTRICTED USE
END OF I_MARD,
BEGIN OF I_EKPO OCCURS 0,
EBELN LIKE EKPO-EBELN, "PURCHASING DOCUMENT NUMBER
EBELP LIKE EKPO-EBELP, "ITEM NUMBER OF PURCHASING DOCUMENT
MATNR LIKE EKPO-MATNR, "MATERIAL NUMBER
END OF I_EKPO,
BEGIN OF I_VBAP OCCURS 0,
VBELN LIKE VBAP-VBELN, "SALES DOCUMENT
POSNR LIKE VBAP-POSNR, "SALES DOCUMENT ITEM
MATNR LIKE VBAP-MATNR, "MATERIAL NUMBER
END OF I_VBAP,
BEGIN OF I_OUT OCCURS 0,
MATNR LIKE MARC-MATNR,
WERKS LIKE MARC-WERKS,
LVORM LIKE MARC-LVORM,
DISPO LIKE MARC-DISPO,
MBRSH LIKE MARA-MBRSH,
MEINS LIKE MARA-MEINS,
MATKL LIKE MARA-MATKL,
VKORG LIKE MVKE-VKORG,
VTWEG LIKE MVKE-VTWEG,
SPRAS LIKE MAKT-SPRAS,
MAKTX LIKE MAKT-MAKTX,
LGORT LIKE MARD-LGORT,
LABST LIKE MARD-LABST,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
END OF I_OUT,
BEGIN OF I_HEADING OCCURS 0,
TEXT1(20),
TEXT2(20),
TEXT3(20),
TEXT4(20),
TEXT5(20),
TEXT6(20),
TEXT7(20),
TEXT8(20),
TEXT9(20),
TEXT10(20),
TEXT11(40),
TEXT12(20),
TEXT13(20),
TEXT14(20),
TEXT15(20),
TEXT16(20),
TEXT17(20),
END OF I_HEADING.
*& S E L E C T I O N - S C R E E N *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-100.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR. "OBLIGATORY.
PARAMETERS: P_WERKS LIKE MARC-WERKS. "OBLIGATORY.
SELECT-OPTIONS: S_LGORT FOR MARD-LGORT,
S_DISPO FOR MARC-DISPO,
S_EBELN FOR EKPO-EBELN .
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-101.
PARAMETERS : RB1 RADIOBUTTON GROUP G1,
RB2 RADIOBUTTON GROUP G1,
RB3 RADIOBUTTON GROUP G1.
SELECTION-SCREEN END OF BLOCK B2.
*& S T A R T - O F - S E L E C T I O N *
START-OF-SELECTION.
SELECT MATNR WERKS LVORM DISPO FROM MARC
INTO CORRESPONDING FIELDS OF TABLE I_MARC
WHERE MATNR IN S_MATNR
AND DISPO IN S_DISPO
AND WERKS = P_WERKS.
IF I_MARC[] IS INITIAL.
WRITE:/ 'NO MATCHING DATA AVAILABLE FROM MARC'.
EXIT.
ENDIF.
PERFORM PURCHASEDATA_VALIDATION.
PERFORM SALESDATA_VALIDATION.
SELECT MATNR LGORT LABST FROM MARD INTO TABLE I_MARD
FOR ALL ENTRIES IN I_MARC
WHERE MATNR = I_MARC-MATNR
AND WERKS EQ P_WERKS
AND LGORT IN S_LGORT.
IF I_MARD[] IS INITIAL.
WRITE:/ 'NO MATCHING DATA AVAILABLE FROM MARD'.
EXIT.
ENDIF.
SELECT MATNR VKORG VTWEG FROM MVKE INTO TABLE I_MVKE
FOR ALL ENTRIES IN I_MARC
WHERE MATNR = I_MARC-MATNR.
IF I_MVKE[] IS INITIAL.
WRITE:/ 'NO MATCHING DATA AVAILABLE FROM MVKE'.
EXIT.
ENDIF.
LOOP AT I_MARC.
MOVE-CORRESPONDING I_MARC TO I_OUT.
CLEAR MARC.
SELECT SINGLE MATNR MBRSH MEINS MATKL FROM MARA
INTO CORRESPONDING FIELDS OF MARA
WHERE MATNR = I_OUT-MATNR.
IF SY-SUBRC = 0.
MOVE: MARA-MBRSH TO I_OUT-MBRSH,
MARA-MEINS TO I_OUT-MEINS,
MARA-MATKL TO I_OUT-MATKL.
ELSE.
CONTINUE.
ENDIF.
SELECT SINGLE MATNR MAKTX SPRAS FROM MAKT
INTO CORRESPONDING FIELDS OF MAKT
WHERE MATNR = I_OUT-MATNR.
IF SY-SUBRC = 0.
MOVE: MAKT-MAKTX TO I_OUT-MAKTX,
MAKT-SPRAS TO I_OUT-SPRAS.
ELSE.
CONTINUE.
ENDIF.
LOOP AT I_EKPO WHERE MATNR = I_MARC-MATNR.
MOVE: I_EKPO-EBELN TO I_OUT-EBELN,
I_EKPO-EBELP TO I_OUT-EBELP.
ENDLOOP.
LOOP AT I_VBAP WHERE MATNR = I_MARC-MATNR.
MOVE: I_VBAP-VBELN TO I_OUT-VBELN,
I_VBAP-POSNR TO I_OUT-POSNR.
ENDLOOP.
LOOP AT I_MARD WHERE MATNR = I_MARC-MATNR.
MOVE: I_MARD-LABST TO I_OUT-LABST,
I_MARD-LGORT TO I_OUT-LGORT.
ENDLOOP.
LOOP AT I_MVKE WHERE MATNR = I_MARC-MATNR.
MOVE: I_MVKE-VKORG TO I_OUT-VKORG,
I_MVKE-VTWEG TO I_OUT-VTWEG.
APPEND I_OUT.
ENDLOOP.
CLEAR I_OUT.
ENDLOOP.
PERFORM OPTIONS.
FORM OPTIONS *
FORM OPTIONS.
IF RB2 = 'X'.
PERFORM FIELDCAT.
PERFORM OUTPUT.
ELSE.
IF RB1 = 'X'.
PERFORM HEADINGS.
PERFORM DLOAD.
ELSE.
IF RB3 = 'X'.
PERFORM HEADINGS.
PERFORM DLOAD.
PERFORM FIELDCAT.
PERFORM OUTPUT.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. "OPTIONS
FORM HEADINGS *
FORM HEADINGS.
I_HEADING-TEXT1 = 'MATNR'.
I_HEADING-TEXT2 = 'WERKS'.
I_HEADING-TEXT3 = 'LVORM'.
I_HEADING-TEXT4 = 'DISPO'.
I_HEADING-TEXT5 = 'MBRSH'.
I_HEADING-TEXT6 = 'MEINS'.
I_HEADING-TEXT7 = 'MATKL'.
I_HEADING-TEXT8 = 'VKORG'.
I_HEADING-TEXT9 = 'VTWEG'.
I_HEADING-TEXT10 = 'SPRAS'.
I_HEADING-TEXT11 = 'MAKTX'.
I_HEADING-TEXT12 = 'LGORT'.
I_HEADING-TEXT13 = 'LABST'.
I_HEADING-TEXT14 = 'EBELN'.
I_HEADING-TEXT15 = 'EBELP'.
I_HEADING-TEXT16 = 'VBELN'.
I_HEADING-TEXT17 = 'POSNR'.
APPEND I_HEADING.
ENDFORM. "HEADINGS
FORM DLOAD *
FORM DLOAD.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\MATSTK.XLS'
FILETYPE = 'DAT'
WRITE_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = I_HEADING
EXCEPTIONS
FILE_WRITE_ERROR = 1.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\MATSTK.XLS'
FILETYPE = 'DAT'
APPEND = 'X'
WRITE_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = I_OUT.
ENDFORM. "DLOAD
FORM FIELDCAT *
FORM FIELDCAT.
V_FIELDCAT-COL_POS = '1'.
V_FIELDCAT-FIELDNAME = 'MATNR'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-HOTSPOT = 'X'.
V_FIELDCAT-REF_FIELDNAME = 'MATNR'.
V_FIELDCAT-REF_TABNAME = 'MARC'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '2'.
V_FIELDCAT-FIELDNAME = 'WERKS'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'WERKS'.
V_FIELDCAT-REF_TABNAME = 'MARC'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '3'.
V_FIELDCAT-FIELDNAME = 'LVORM'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'LVORM'.
V_FIELDCAT-REF_TABNAME = 'MARC'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '4'.
V_FIELDCAT-FIELDNAME = 'DISPO'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'DISPO'.
V_FIELDCAT-REF_TABNAME = 'MARC'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '5'.
V_FIELDCAT-FIELDNAME = 'MBRSH'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'MBRSH'.
V_FIELDCAT-REF_TABNAME = 'MARA'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '6'.
V_FIELDCAT-FIELDNAME = 'MEINS'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'MEINS'.
V_FIELDCAT-REF_TABNAME = 'MARA'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '7'.
V_FIELDCAT-FIELDNAME = 'MATKL'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'MATKL'.
V_FIELDCAT-REF_TABNAME = 'MARA'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '8'.
V_FIELDCAT-FIELDNAME = 'VKORG'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'VKORG'.
V_FIELDCAT-REF_TABNAME = 'MVKE'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '9'.
V_FIELDCAT-FIELDNAME = 'VTWEG'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'VTWEG'.
V_FIELDCAT-REF_TABNAME = 'MVKE'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '10'.
V_FIELDCAT-FIELDNAME = 'SPRAS'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'SPRAS'.
V_FIELDCAT-REF_TABNAME = 'MAKT'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '11'.
V_FIELDCAT-FIELDNAME = 'MAKTX'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'MAKTX'.
V_FIELDCAT-REF_TABNAME = 'MAKT'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '12'.
V_FIELDCAT-FIELDNAME = 'LGORT'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'LGORT'.
V_FIELDCAT-REF_TABNAME = 'MARD'.
V_FIELDCAT-SELTEXT_L = 'STRG LOCT'.
V_FIELDCAT-OUTPUTLEN = 10.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '13'.
V_FIELDCAT-FIELDNAME = 'LABST'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-SELTEXT_M = 'STOCK'.
V_FIELDCAT-OUTPUTLEN = 15.
V_FIELDCAT-REF_FIELDNAME = 'LABST'.
V_FIELDCAT-REF_TABNAME = 'MARD'.
V_FIELDCAT-DO_SUM = 'X'.
V_LAYOUT-TOTALS_TEXT = 'TOTAL STOCK:'.
V_FIELDCAT-HOTSPOT = 'X'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '14'.
V_FIELDCAT-FIELDNAME = 'EBELN'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-HOTSPOT = 'X'.
V_FIELDCAT-REF_FIELDNAME = 'EBELN'.
V_FIELDCAT-REF_TABNAME = 'EKPO'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '15'.
V_FIELDCAT-FIELDNAME = 'EBELP'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'EBELP'.
V_FIELDCAT-REF_TABNAME = 'EKPO'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '16'.
V_FIELDCAT-FIELDNAME = 'VBELN'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-HOTSPOT = 'X'.
V_FIELDCAT-REF_FIELDNAME = 'VBELN'.
V_FIELDCAT-REF_TABNAME = 'VBAP'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '17'.
V_FIELDCAT-FIELDNAME = 'POSNR'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'POSNR'.
V_FIELDCAT-REF_TABNAME = 'VBAP'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
ENDFORM. "FIELDCAT
FORM OUTPUT *
FORM OUTPUT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE'
I_GRID_TITLE = 'CLICK ON MATERIAL/PURDOC/SALESDOC FOR DETAILS'
I_CALLBACK_USER_COMMAND = 'DISPLAYDETAILS'
IS_LAYOUT = V_LAYOUT
IT_FIELDCAT = VT_FIELDCAT1
TABLES
T_OUTTAB = I_OUT.
IF SY-SUBRC <> 0.
ENDIF.
ENDFORM. "OUTPUT
FORM TOP-OF-PAGE *
FORM TOP-OF-PAGE.
DATA: T_HEADER TYPE SLIS_T_LISTHEADER,
WA_HEADER TYPE SLIS_LISTHEADER.
WA_HEADER-TYP = 'H'.
WA_HEADER-INFO = 'REPORT FOR : '.
APPEND WA_HEADER TO T_HEADER.
CLEAR WA_HEADER.
WA_HEADER-TYP = 'S'.
WA_HEADER-INFO = 'MATERIAL DETAILS'.
APPEND WA_HEADER TO T_HEADER.
CLEAR WA_HEADER.
WA_HEADER-TYP = 'S'.
WA_HEADER-INFO = 'PURCHASE ORDER DETAILS'.
APPEND WA_HEADER TO T_HEADER.
CLEAR WA_HEADER.
WA_HEADER-TYP = 'S'.
WA_HEADER-INFO = 'SALES ORDER DETAILS'.
APPEND WA_HEADER TO T_HEADER.
CLEAR WA_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
I_LOGO = 'GEAR'
IT_LIST_COMMENTARY = T_HEADER.
ENDFORM. "TOP-OF-PAGE
*& FORM PURCHASEDATA_VALIDATION *
FORM PURCHASEDATA_VALIDATION.
SELECT EBELN EBELP MATNR
FROM EKPO
INTO TABLE I_EKPO
FOR ALL ENTRIES IN I_MARC
WHERE MATNR = I_MARC-MATNR
AND EBELN IN S_EBELN
AND WERKS EQ P_WERKS.
IF I_EKPO[] IS INITIAL.
WRITE:/ 'NO MATCHING DATA IS SELECTED FROM TABLE EKPO'.
EXIT.
ENDIF.
DATA: T_EKPO LIKE I_EKPO OCCURS 0 WITH HEADER LINE.
T_EKPO[] = I_EKPO[].
REFRESH I_EKPO.
FREE I_EKPO.
LOOP AT T_EKPO.
SELECT SINGLE EBELN FROM EKKO INTO EKPO-EBELN
WHERE EBELN = T_EKPO-EBELN.
IF SY-SUBRC = 0.
MOVE-CORRESPONDING T_EKPO TO I_EKPO.
APPEND I_EKPO.
CLEAR I_EKPO.
ELSE.
CONTINUE.
ENDIF.
ENDLOOP.
SORT I_EKPO.
ENDFORM. "PURCHASEDATA_VALIDATION
*& FORM SALESDATA_VALIDATION *
FORM SALESDATA_VALIDATION.
SELECT VBELN POSNR MATNR
FROM VBAP
INTO CORRESPONDING FIELDS OF TABLE
I_VBAP FOR ALL ENTRIES IN I_MARC
WHERE MATNR = I_MARC-MATNR.
DATA: T_VBAP LIKE I_VBAP OCCURS 0 WITH HEADER LINE.
T_VBAP[] = I_VBAP[].
REFRESH I_VBAP.
FREE I_VBAP.
LOOP AT T_VBAP.
SELECT SINGLE VBELN FROM VBAK INTO VBAK-VBELN
WHERE VBELN = T_VBAP-VBELN.
IF SY-SUBRC = 0.
MOVE-CORRESPONDING T_VBAP TO I_VBAP.
APPEND I_VBAP.
CLEAR I_VBAP.
ELSE.
CONTINUE.
ENDIF.
ENDLOOP.
SORT I_VBAP.
ENDFORM. "SALESDATA_VALIDATION
Similar Messages
-
User unable to view Excel button in ALV grid. Has full authorization
Hi All,
A user in our copany is unable to view Excel button in ALV grid. Has full authorization to S_BDS_DS, S_ALV_LAYOUT.
Please note that this is not the export to Excel button. Its the excel icon which enables the users to view the output in excel format on screen.
I am able to view the Excel Button. can you pls advise what might be the possible root cause.
Are there any authorization objects as well that govern ALV Grid buttons (excel) display.
Please help.
Can we add/delete the buttongs in the ALV grid from somewhere..
Thanks,PhaniHi,
oic, only specific user, not all user.
I have a similar problem with you, but not excel button but inbox button on initial screen (session_manager)
deleting this user and re-create this user solved my problem.
hope it help you.
rgds,
Alfonsus Guritno -
Excel view in ALV Grid---- Urgent
Hi,
On executing sample porgram BCALV_FULLSCREEN_DEMO, we get ALV grid display. After that, on Clicking "<b>Microsoft Excel View(controlshiftF7)</b>" we are getting blanck Excel screen view instead of the field values.
I have the same scenario requirement in real time. I want the excel screen with values from ALV Grid.
Thanks in Advance.
-Mohan.Hi Mohan,
Try this:
Download Data in EXCEL from ALV list display
1) Once you have alv report displayed in the screen.
2) Click button 'View' ( next to print button) on application toolbar
3) Select Excel in Place
4) This will download the same format as of Report
I hope your ALV have all the Standard functions in Toolbar. If not copy the status from and get the function as mentioned above.
<b>Program - SAPLSALV
Status - STANDARD</b>
Reward points if this Helps.
Manish -
Problem with back button in alv o/p
Hi guys,
I am using Grid display to display a data. but when i am clicking on back button on o/p the o/p is displaying duplicate records for the first o/p. i,e it is displaying multiple records, again clicking on back it displaying extended o/p with more duplicate data...Hi
Check did u refreshed the internal that u displayed.
And also check grid control is initial or not
Data: g_cust_container TYPE REF TO cl_gui_custom_container,
g_cust_grid TYPE REF TO cl_gui_alv_grid.
**Create Container ALV Grid
IF g_cust_grid IS INITIAL.
Create Control Container for Grid
CREATE OBJECT g_cust_container
EXPORTING
container_name = g_container.
IF sy-subrc <> 0.
add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = sy-repid
txt2 = sy-subrc
txt1 = text-m02. "The control could not be created.
ENDIF.
CREATE OBJECT g_cust_grid
EXPORTING
i_parent = g_cust_container.
ENDIF.
CALL METHOD g_cust_grid->refresh_table_display.
Regards,
Raghu. -
Problem with total button in alv..?
Hi abapers,
i am facing a problem with standard alv total button
all the others button r working fine
but when i am trying to add any column total by using standard total button
its throwing dump..
Can anyone tell me wat to doHi Aarif Baig,
Paste your dump analysis...
what dump you are geting and source code for your field catelog... ??
as well as which field you are removing from your fieldcatelog so that dump is not coming... ??
and code for that field in fieldcatelog ??
and is the type of that filed in fileld catelog and internal table is same or not... ??
if i am not wrong you will be getting dump for message x000..
Please give complete details what you did with little source code and dump analysis....
Hope it will solve your problem..
Thanks & Regards
ilesh 24x7
ilesh Nandaniya -
What is the excel button in alv grid supposed to do?
Hi All.
In the ALV reports, we see an Excel button too.
But on pressing it, a blank excel sheet opens, and there is no way to go out of it. We have to exit the report.
What is it supposed to do?
Thanks everybody !Hi Aishi,
Yes you are correct.Well i would change my previous statement :
EXCEL/Word Processing is not to open a BLANK SHEET, but to open an EXCEL/WORD document and paste the ALV output data into the Sheet. You have several option when you click on EXCEL. You can paste the ouput as a PIVOT TABLE in excel sheet or Excel SAP Macros or a normal table.
Open program <b>BCALV_FULLSCREEN_GRID_EDIT</b> in SE38 and execute it. Click EXCEL. And follow the directions. It will copy paste the code from the ALV output into Excel/Word File.
The difference in EXPORT is that in EXPORT, you can download it in different formats ( VIz. excel, text etc ) without any formatting ( COlors etc.). But in the EXCEL button case, the data is copied and has different colours for columns etc.
Best regards,
Prashant -
Problem with check box in ALV Grid Display
I am Displaying Material Master Data in ALV Grid Display with Check Box for each record and if i checked check box then i am processing Update operation in Database, my question is after perform update operation check box should be clear.
Kindly help me!!!!Hello Raj
Given the fact that you do not tell us the most important piece of information (namely whether you are using OO-based ALV or not) I assume you are using fm-based ALV lists.
In this case you probably have defined a USER_COMMAND routine as described in the documentation of the fm.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
* define local data
DATA: ls_outtab LIKE LINE OF gt_outtab,
ld_idx TYPE i.
LOOP AT gt_outtab INTO ls_outtab
WHERE ( chkbox = 'X' ).
ld_idx = syst-tabix.
" Call your update function / method / perform
ls_outtab-chkbox = space.
MODIFY gt_outtab FROM ls_outtab INDEX ld_Idx
TRANSPORTING chkbox.
ENDLOOP.
" And now trigger refresh of the ALV display:
rs_selfield-refresh = 'X'. " <<< !!!
ENDFORM.
Regards
Uwe -
Problem with print preview in alv grid
Hello all,
I have to display base unit of measure(meins) in alv grid output. i am using a conversion routine to convert it from ST TO PC before display.After executing the report i am getting the correct data. the problem is when i select the print preview
alv list is displayed. in that the unit of measure pc is not displayed, it is comming as '*******. what i came to know is the same conversion routine is triggered in the standard program for the display. so it canot convert that.
so please help me out in solving this.
Thanks in advance,
Sarathi sarath,
this is an example code try using the statement before displaying, i think it works.
*example cdoe.
LOOP AT i_grp1 INTO wa_grp1.
AT NEW tknum.
READ TABLE i_grp1 intto wa_grp1 index sy-tabix.
SUM.
MOVE-CORRESPONDING wa_grp1 TO wa_grp2.
APPEND wa_grp2 TO i_grp2.
ENDAT.
ENDLOOP. -
Problems with F4 help in ALV grid
Hi all,
I am trying to create a F4 help for the field Payee number in my reprot output (ALV Grid OO), i am able to get the window for selection of the value in the F4 help , but i am unable to pass the value back on to the screen.
I need to insert the selected value from the F4 help and aslo need to populate the Name of the payee into the Payee field.
Can some one help me in finding what error have i done in the code.
Thanks in advance for all.
I have the following code
*& Include ZRMM_ALV_TOP *
data: gc_control100 type ref to cl_gui_custom_container,
gc_control101 type ref to cl_gui_custom_container.
data: gi_outtab100 type table of ty_purchase.
data: g_cont0100 type ref to cl_gui_custom_container,
g_grid0100 type ref to cl_gui_alv_grid, " For Screen 100 Grid
gi_fcat0100 type lvc_t_fcat, " Field Catalog for Screen 100
gi_sort0100 type lvc_t_sort,
g_lout0100 type lvc_s_layo.
data: okcode_100 like sy-ucomm,
save_0100 like sy-ucomm,
okcode_200 like sy-ucomm,
save_0200 like sy-ucomm.
types: begin of f4_itab_type,
LIFNR type lifnr,
BUKRS type name1,
end of f4_itab_type.
data: f4_itab type table of f4_itab_type,
ls_f4_itab type f4_itab_type.
data : it_IZEMTAB type table of IZEMTAB,
wa_IZEMTAB type IZEMTAB.
Class Definitions.
class event_receiver_0100 definition.
PUBLIC SECTION.
types: begin of onf4_event_parameters_type,
c_fieldname type lvc_fname,
cs_row_no type lvc_s_roid,
cr_event_data type ref to cl_alv_event_data,
ct_bad_cells type lvc_t_modi,
c_display type char01,
end of onf4_event_parameters_type.
data: fieldcatalog type lvc_t_fcat.
data : f4_alv type ref to cl_gui_alv_grid,
f4_cont type ref to cl_gui_custom_container.
data: f4_params type onf4_event_parameters_type.
METHODS:
ON_F4 FOR EVENT ONF4 of cl_gui_alv_grid
importing sender
e_fieldname
e_fieldvalue
es_row_no
er_event_data
et_bad_cells
e_display.
on_data_changed for event
data_changed of cl_gui_alv_grid
importing e_onf4
e_onf4_before
e_onf4_after
er_data_changed
e_ucomm
sender.
endclass. "lcl_event_receiver DEFINITION
data: gs_variant type disvariant,
gc_save value 'A',
gs_toolbar TYPE stb_button,
gs_toolbar1 type stb_button,
gs_toolbar2 type stb_button.
DATA : T_RETURN TYPE STANDARD TABLE OF DDSHRETVAL WITH HEADER LINE.
DATA : event_receiver_0100 TYPE REF TO EVENT_RECEIVER_0100.
Class Implementation.
class event_receiver_0100 implementation.
For f4 help.
method on_f4.
data: ls_outtab type ty_purchase.
field-symbols <itab> type lvc_t_modi.
data: ls_modi type lvc_s_modi,
ls_f4_itab type f4_itab_type.
f4_params-c_fieldname = e_fieldname.
f4_params-cs_row_no = es_row_no.
f4_params-cr_event_data = er_event_data.
f4_params-ct_bad_cells = et_bad_cells.
f4_params-c_display = e_display.
read table it_purchase into ls_outtab index f4_params-cs_row_no-row_id.
Clear f4_itab[].
CALL FUNCTION 'FI_VENDOR_ALTERN_PAYERS_READ'
EXPORTING
I_LIFNR = ls_outtab-lifnr
I_BUKRS = ls_outtab-bukrs
TABLES
T_ZEMTAB = it_izemtab.
clear f4_itab[].
if not ls_outtab-lifnr is initial.
loop at it_izemtab into wa_izemtab.
ls_f4_itab-LIFNR = wa_izemtab-empfb.
ls_f4_itab-BUKRS = wa_izemtab-name1.
append ls_f4_itab to f4_itab.
endloop.
endif.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = 'LIFNR'
DYNPPROG = sy-repid
DYNPNR = '100'
WINDOW_TITLE = 'f4 help for PAYEE'
VALUE_ORG = 'S'
TABLES
VALUE_TAB = f4_itab
RETURN_TAB = T_RETURN.
IF SY-SUBRC <> 0.
ENDIF.
assign f4_params-cr_event_data->m_data->* to <itab>.
ls_modi-row_id = f4_params-cs_row_no-row_id.
read table f4_itab into ls_f4_itab index es_row_no-row_id.
if not f4_itab is initial.
ls_modi-row_id = es_row_no-row_id.
ls_modi-value = ls_f4_itab-LIFNR.
ls_modi-FIELDNAME = 'LIFNR'.
append ls_modi to <itab>.
ls_modi-row_id = es_row_no-row_id.
ls_modi-value = ls_f4_itab-BUKRS.
ls_modi-FIELDNAME = 'NAME1'.
append ls_modi to <itab>.
endif.
er_event_data->m_event_handled = 'X'.
ENDMETHOD.
*--ENDMETHOD SHOW_F4--
endclass. "lcl_event_receiver IMPLEMENTATIONI have used the following FM for F4 help on editable ALV grid column and it worked fine.Try the below.
Call function for Input helps
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
i_title = text-049
i_selection = c_check
i_zebra = c_check
i_screen_start_column = 55
i_screen_end_column = 125
i_screen_start_line = 10
i_screen_end_line = 20
i_tabname = c_fcat_str
it_fieldcat = tl_fieldcat
IMPORTING
es_selfield = wal_selfield
TABLES
t_outtab = tl_code
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSEIF sy-subrc = 0 AND NOT wal_selfield IS INITIAL.
wl_index = wal_selfield-tabindex.
READ TABLE tl_code ASSIGNING <l_code>
INDEX wl_index.
IF sy-subrc = 0.
<l_fgis_lots>-status = <l_code>.
ENDIF.
ENDIF.
ENDIF. -
Problem with 'BACK' option for ALV grid
Hi Friends,
I'm using FM, REUSE_ALV_GRID_DISPLAY in my report.
Once I got an ALV output, when I press the BACK button,
it's going to blank sceen again when I press BACK am getting selection screen.
From output am not able to goto the selection screen. Kindly suggest on this issue.
Thanks in advance.
Regards,
Bharat.Hi,
I don't have write statement anywhere in my prog.
pls refer to the code.
REPORT ZCDC_TRACKING_REPORT no standard page heading message-id zz1
tables:vbak,
vbap,
vbkd,
vtfa,
vbfa,
vtrkh,
vttk.
TYPE-POOLS: SLIS. "Field catalog structure
DATA: FCATALOG TYPE SLIS_FIELDCAT_ALV OCCURS 30.
DATA: FZEILE TYPE SLIS_FIELDCAT_ALV OCCURS 30 with header line.
data:w_disp_variant TYPE disvariant,
s_alv_layout type slis_layout_alv.
DATA: W_REPID LIKE SY-REPID,
W_SUBRC LIKE SY-SUBRC,
W_LOOPCOUNT LIKE SY-TABIX,
W_LINES TYPE I,
IS_VARIANT LIKE DISVARIANT,
GS_LAYOUT TYPE SLIS_LAYOUT_ALV.
*Internal table declaration.
data: begin of i_vbak occurs 0,
vbeln like vbak-vbeln,
kunnr like vbak-kunnr,
bstnk like vbak-bstnk,
end of i_vbak.
data: begin of i_vbfa occurs 0,
vbeln like vbfa-vbeln,
vbelv like vbfa-vbelv,
end of i_vbfa.
data: begin of i_vtfa occurs 0,
tknum like vtfa-tknum,
vbeln like vbak-vbeln,
end of i_vtfa.
data: begin of i_vttp occurs 0,
tknum like vtfa-tknum,
vbeln like vbak-vbeln,
end of i_vttp.
data: begin of i_vttk occurs 0,
tknum like vtfa-tknum,
vsart like vttk-vsart,
dtabf like vttk-dtabf,
tdlnr like vttk-tdlnr,
TNDR_TRKID like vttk-TNDR_TRKID,
end of i_vttk.
data: begin of i_final occurs 0,
kunnr like vbak-kunnr,
name1 like kna1-name1,
vbeln like vbak-vbeln,
bstkd like vbkd-bstkd,
dtabf like vttk-dtabf,
tdlnr like vttk-tdlnr,
TNDR_TRKID like vttk-TNDR_TRKID,
end of i_final,
wa_final like i_final.
data: v_name1 like kna1-name1,
v_trackno like vtrkh-trackn.
**selection-screen.
SELECTION-SCREEN begin of block b1 with frame.
parameters: R1 RADIOBUTTON GROUP rad1 DEFAULT 'X'.
parameters: p_vbeln like vbak-vbeln,
p_bstkd like vbkd-bstkd.
SKIP.
SKIP.
*SELECTION-SCREEN end of block b1.
*SELECTION-SCREEN begin of block b2.
parameters: R2 RADIOBUTTON GROUP rad1.
select-options: s_kunnr for vbak-kunnr.
select-options: s_dtabf for VTTK-DTABF.
SELECTION-SCREEN end of block b1.
SELECTION-SCREEN begin of block b2 with frame.
parameters: P_track RADIOBUTTON GROUP rad2 default 'X',
P_car RADIOBUTTON GROUP rad2,
P_both RADIOBUTTON GROUP rad2.
SELECTION-SCREEN end of block b2.
**Initialization.
Initialization.
MOVE SY-REPID TO W_REPID.
*At selection-screen.
At selection-screen.
if R1 eq 'X'.
if p_vbeln eq ' ' and p_bstkd eq ' '.
message e000(zz1) with 'Please enter either PO # or SO #'.
endif.
elseif R2 eq 'X'.
if ( s_kunnr-low is initial and s_kunnr-high is initial ) and
( s_dtabf-low is initial and s_dtabf-high is initial ) .
message e000(zz1) with 'Please limit your selection criteria, this'
'cannot run without a Customer # & Date range'.
endif.
endif.
**start-of-selection.
start-of-selection.
**if option foreground is selected
IF R1 eq 'X'.
**step1 select data from VBAK,VBKD
**step2 select data from VTTK
perform get_data_foreground.
Perform process_data.
elseif R2 eq 'X'.
**if option Batch processing selected
**select data from KNA1,VBAK,VTTKelseif R2 eq 'X'.
perform get_data_batch_processing.
endif.
Perform process_data.
end-of-selection.
*& Form get_data_foreground
text
--> p1 text
<-- p2 text
form get_data_foreground .
if p_vbeln ne ' ' and p_bstkd ne ' '.
select vbeln
kunnr
bstnk
from vbak into table i_vbak
where vbeln eq p_vbeln
and bstnk eq p_bstkd.
elseif p_vbeln eq ' ' .
select vbeln
kunnr
bstnk
from vbak into table i_vbak
where bstnk eq p_bstkd.
elseif p_bstkd eq ' '.
select vbeln
kunnr
bstnk
from vbak into table i_vbak
where vbeln eq p_vbeln.
endif.
**Get data from VBFA
if not i_vbak[] is initial.
select vbeln
vbelv from VBFA into table i_vbfa
for all entries in i_vbak
where vbelv = i_vbak-vbeln
and vbtyp_n = 'J'.
endif.
**select data from VTTP
if not i_vbfa[] is initial.
select tknum
vbeln
from vttp into table i_vttp
for all entries in i_vbfa
where vbeln = i_vbfa-vbeln.
endif.
*select data from VTTK
if not i_vttp[] is initial.
select tknum
vsart
dtabf
tdlnr
TNDR_TRKID from vttk into table i_vttk
for all entries in i_vttp
where tknum eq i_vttp-tknum.
endif.
**select data from VTFA
if not i_vbak[] is initial.
select tknum
vbeln
from vtfa into table i_vtfa
for all entries in i_vbak
where vbeln = i_vbak-vbeln.
endif.
*select data from VTTK
if not i_vtfa[] is initial.
select tknum
dtabf
tdlnr
TNDR_TRKID from vttk into table i_vttk
for all entries in i_vtfa
where tknum eq i_vtfa-tknum.
endif.
endform. " get_data_foreground
*& Form get_data_batch_processing
text
--> p1 text
<-- p2 text
form get_data_batch_processing .
select vbeln
kunnr
bstnk
from vbak into table i_vbak
where kunnr in s_kunnr.
**Get data from VBFA
if not i_vbak[] is initial.
select vbeln from VBFA into table i_vbfa
for all entries in i_vbak
where vbelv = i_vbak-vbeln
and vbtyp_n = 'J'.
endif.
**select data from VTTP
if not i_vbfa[] is initial.
select tknum
vbeln
from vttp into table i_vttp
for all entries in i_vbfa
where vbeln = i_vbfa-vbeln.
endif.
*select data from VTTK
if not i_vttp[] is initial.
select tknum
vsart
dtabf
tdlnr
TNDR_TRKID from vttk into table i_vttk
for all entries in i_vttp
where tknum eq i_vttp-tknum
and dtabf eq s_dtabf.
endif.
**select data from VTFA
if not i_vbak[] is initial.
select tknum
vbeln
from vtfa into table i_vtfa
for all entries in i_vbak
where vbeln = i_vbak-vbeln.
endif.
**select data from VTTK
if not i_vtfa[] is initial.
select tknum
dtabf
tdlnr
TNDR_TRKID from vttk into table i_vttk
for all entries in i_vtfa
where tknum eq i_vtfa-tknum
and dtabf eq s_dtabf.
endif.
endform. " get_data_batch_processing
*& Form process_data
text
--> p1 text
<-- p2 text
form process_data .
**loop processing
loop at i_vbak.
wa_final-vbeln = i_vbak-vbeln.
wa_final-bstkd = i_vbak-bstnk.
wa_final-kunnr = i_vbak-kunnr.
select single name1 into v_name1
from kna1
where kunnr eq wa_final-kunnr.
if sy-subrc eq 0.
wa_final-name1 = v_name1.
endif.
read table i_vbfa with key vbelv = i_vbak-vbeln.
if sy-subrc eq 0.
read table i_vttp with key vbeln = i_vbfa-vbeln.
if sy-subrc eq 0.
read table i_vttk with key tknum = i_vttp-tknum.
if sy-subrc eq 0.
wa_final-dtabf = i_vttk-dtabf.
if p_track eq 'X'.
if i_vttk-vsart = 'LTL'.
wa_final-TNDR_TRKID = i_vttk-TNDR_TRKID.
else.
select single trackn from VTRKH into v_trackno
where uevbeln = i_vbfa-vbeln
and uevbtyp = 'J'
and vbtyp = 'X'.
if sy-subrc eq 0.
wa_final-TNDR_TRKID = v_trackno.
endif.
endif.
elseif P_car eq 'X'.
wa_final-tdlnr = i_vttk-tdlnr.
else.
wa_final-tdlnr = i_vttk-tdlnr.
if i_vttk-vsart = 'LTL'.
wa_final-TNDR_TRKID = i_vttk-TNDR_TRKID.
else.
select single trackn from VTRKH into v_trackno
where uevbeln = i_vbfa-vbeln
and uevbtyp = 'J'
and vbtyp = 'X'.
if sy-subrc eq 0.
wa_final-TNDR_TRKID = v_trackno.
endif.
endif.
endif.
endif.
endif.
endif.
append wa_final to i_final.
clear : i_final, wa_final,i_vbak,i_vbfa,i_vttp, i_vttk,v_name1.
endloop.
IF R1 eq 'X'.
PERFORM FIELDCATALOG.
PERFORM LAYOUT_BUILD CHANGING GS_LAYOUT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_REPID
IS_LAYOUT = GS_LAYOUT
IT_FIELDCAT = FCATALOG
TABLES
T_OUTTAB = i_final
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
else.
PERFORM BACKGROUND_JOB.
**Transfer of data into Application server
OPEN DATASET P_PFILE for output IN TEXT MODE encoding DEFAULT .
if sy-subrc eq 0.
loop at itab.
transfer itab to p_pfile.
endloop.
else.
message e000(zz1) with p_pfile.
endif.
CLOSE dataset p_pfile.
endif.
endform. " process_data
*& Form FIELDCATALOG
text
--> p1 text
<-- p2 text
form FIELDCATALOG .
DATA: L_FIELDNO LIKE SY-TABIX.
L_FIELDNO = 1.
**Cust. Number
CLEAR FZEILE.
FZEILE-COL_POS = L_FIELDNO.
L_FIELDNO = L_FIELDNO + 1.
FZEILE-FIELDNAME = 'KUNNR'.
FZEILE-DATATYPE = 'CHAR'.
FZEILE-OUTPUTLEN = 15.
FZEILE-SELTEXT_L = 'Customer' .
FZEILE-LOWERCASE = 'X'.
FZEILE-SP_GROUP = 'A'.
FZEILE-KEY = 'X'.
FZEILE-DDICTXT = 'M'. " medium text
APPEND FZEILE TO FCATALOG.
**Customer name
CLEAR FZEILE.
FZEILE-COL_POS = L_FIELDNO.
L_FIELDNO = L_FIELDNO + 1.
FZEILE-FIELDNAME = 'NAME1'.
FZEILE-DATATYPE = 'CHAR'.
FZEILE-OUTPUTLEN = 35.
FZEILE-SELTEXT_L = 'Customer Name' .
FZEILE-LOWERCASE = 'X'.
FZEILE-SP_GROUP = 'A'.
FZEILE-KEY = 'X'.
FZEILE-DDICTXT = 'M'. " medium text
APPEND FZEILE TO FCATALOG.
**Sales order
CLEAR FZEILE.
FZEILE-COL_POS = L_FIELDNO.
L_FIELDNO = L_FIELDNO + 1.
FZEILE-FIELDNAME = 'VBELN'.
FZEILE-DATATYPE = 'CHAR'.
FZEILE-OUTPUTLEN = 10.
FZEILE-SELTEXT_L = 'Sales order' .
FZEILE-LOWERCASE = 'X'.
FZEILE-SP_GROUP = 'A'.
FZEILE-KEY = 'X'.
FZEILE-DDICTXT = 'M'. " medium text
APPEND FZEILE TO FCATALOG.
**Custmoer PO
CLEAR FZEILE.
FZEILE-COL_POS = L_FIELDNO.
L_FIELDNO = L_FIELDNO + 1.
FZEILE-FIELDNAME = 'BSTKD'.
FZEILE-DATATYPE = 'CHAR'.
FZEILE-OUTPUTLEN = 30.
FZEILE-SELTEXT_L = 'Custmoer PO' .
FZEILE-LOWERCASE = 'X'.
FZEILE-SP_GROUP = 'A'.
FZEILE-KEY = 'X'.
FZEILE-DDICTXT = 'M'. " medium text
APPEND FZEILE TO FCATALOG.
**Date shipped
CLEAR FZEILE.
FZEILE-COL_POS = L_FIELDNO.
L_FIELDNO = L_FIELDNO + 1.
FZEILE-FIELDNAME = 'DTABF'.
FZEILE-DATATYPE = 'CHAR'.
FZEILE-OUTPUTLEN = 15.
FZEILE-SELTEXT_L = 'Date shipped' .
FZEILE-LOWERCASE = 'X'.
FZEILE-SP_GROUP = 'A'.
FZEILE-KEY = 'X'.
FZEILE-DDICTXT = 'M'. " medium text
APPEND FZEILE TO FCATALOG.
**Carrier
CLEAR FZEILE.
FZEILE-COL_POS = L_FIELDNO.
L_FIELDNO = L_FIELDNO + 1.
FZEILE-FIELDNAME = 'TDLNR'.
FZEILE-DATATYPE = 'CHAR'.
FZEILE-OUTPUTLEN = 15.
FZEILE-SELTEXT_L = 'Carrier' .
FZEILE-LOWERCASE = 'X'.
FZEILE-SP_GROUP = 'A'.
FZEILE-KEY = 'X'.
FZEILE-DDICTXT = 'M'. " medium text
APPEND FZEILE TO FCATALOG.
**Tracking/Pro #
CLEAR FZEILE.
FZEILE-COL_POS = L_FIELDNO.
L_FIELDNO = L_FIELDNO + 1.
FZEILE-FIELDNAME = 'TNDR_TRKID'.
FZEILE-DATATYPE = 'CHAR'.
FZEILE-OUTPUTLEN = 15.
FZEILE-SELTEXT_L = 'Tracking/Pro#' .
FZEILE-LOWERCASE = 'X'.
FZEILE-SP_GROUP = 'A'.
FZEILE-KEY = 'X'.
FZEILE-DDICTXT = 'M'. " medium text
APPEND FZEILE TO FCATALOG.
CLEAR FZEILE.
endform. " FIELDCATALOG
*& Form LAYOUT_BUILD
text
<--P_GS_LAYOUT text
form LAYOUT_BUILD changing p_gs_layout TYPE SLIS_LAYOUT_ALV.
CLEAR P_GS_LAYOUT.
P_GS_LAYOUT-ZEBRA = 'X'.
P_GS_LAYOUT-BOX_FIELDNAME = SPACE.
P_GS_LAYOUT-MAX_LINESIZE = 250.
endform. " LAYOUT_BUILD
*& Form BACKGROUND_JOB
text
--> p1 text
<-- p2 text
form BACKGROUND_JOB .
DATA: JOB_NAME LIKE TBTCO-JOBNAME,
JOB_NR LIKE TBTCO-JOBCOUNT,
JOB_RELEASED TYPE C,
JOB_START_SOFORT TYPE C.
DATA: TITEL(15) TYPE C,
TEXT1(35) TYPE C,
TEXT2(40) TYPE C,
ANSWER TYPE C.
DATA: PARAMS LIKE PRI_PARAMS,
VALID TYPE C.
JOB_NAME = SYST-REPID.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
JOBNAME = JOB_NAME
IMPORTING
JOBCOUNT = JOB_NR
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 4.
IF SYST-SUBRC NE 0.
MESSAGE I162(00) WITH
'An error occured while creating the background job.'.
STOP.
ELSE.
*set print parameters to output any errors to spool...
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
IMMEDIATELY = ' '
MODE = 'BATCH'
NO_DIALOG = 'X'
RELEASE = 'X'
NEW_LIST_ID = 'X'
LINE_SIZE = SY-LINSZ
*LIST_NAME = 'RBE'
LIST_TEXT = 'Extract Results'
IMPORTING
OUT_PARAMETERS = PARAMS
VALID = VALID
EXCEPTIONS
ARCHIVE_INFO_NOT_FOUND = 1
INVALID_PRINT_PARAMS = 2
INVALID_ARCHIVE_PARAMS = 3
OTHERS = 4.
IF VALID NE SPACE.
*submit job with all the selection screen params...
SUBMIT (JOB_NAME) USER SYST-UNAME
VIA JOB JOB_NAME NUMBER JOB_NR
*WITH CLIENT = CLIENT
*WITH MONIFROM = MONIFROM
*WITH MONI_TO = MONI_TO
*WITH TQ_FROM = TQ_FROM
*WITH TQ_TO = TQ_TO
*WITH WORKLOAD = WORKLOAD
*WITH ALL = ALL
*WITH SPL1 = SPL1
*WITH APPSERV1 = APPSERV1
*WITH SPOOLNR = SPOOLNR
*WITH APPPATH1 = APPPATH1
*WITH PCPATH = PCPATH
*WITH SPL2 = SPL2
*WITH APPSERV2 = APPSERV2
TO SAP-SPOOL SPOOL PARAMETERS PARAMS
WITHOUT SPOOL DYNPRO
AND RETURN.
IF SYST-SUBRC <> 0.
CASE SYST-SUBRC.
WHEN 4.
MESSAGE I162(00) WITH
'Error defining background job!'
' Background job canceled by User.'.
WHEN 8.
MESSAGE I162(00) WITH
'Error defining background job!'
' Error in job scheduling (JOB_SUBMIT)'.
WHEN 12.
MESSAGE I162(00) WITH
'Error defining background job!'
' Error in internal number assignment'.
ENDCASE.
ENDIF.
endif.
endif.
endform. " BACKGROUND_JOB -
Problem with 'Print' button in ALV
Hi All,
I have developed a OOPs based ALV report. When ever we create an ALV we also have to create Menu bar I did that providing fuctionality for 'BACK' and 'CANCEL' buttons in main toolbar. But user wants funtionality for 'SAVE' and 'PRINT'.
How do I do this ? Is there any stadard code which I can paste in PAI and use it. Classic ALVs handle this by default and OOPs doesn't do this it handles only a table level. But in my report I have a header information also. If user uses the standard 'PRINT' button at table level, only table contents are printed not the header information.
Please let me know how to handle 'PRINT' & 'SAVE' button in OOPs ALV.
Thanks in advance.Cancelled
-
Error in clicking save to local file button in alv grid? urgent
>>>>> if lr_tabledescr->applies_to_data( <coltab_any> ) eq 'X'.
exactly i am getting error here
how to rectify this error
Error in clicking save to local file button and mail receipt button in alv grid?In your REUSE_ALV_GRID_DISPLAY
EXPORTING
I_SAVE = 'U'
put this field....and then check it will definitely work... -
Buttons in ALV Grid cell need focus to be clicked :-(
Hi,
I have an ALV Grid with single cells displayed as buttons (dependend on the data in the corresponding row). Unfortunatelly the button-cells need focus to be clicked. So you need two clicks: one to get the focus to the desired cell and one to really click the button.
Any ideas how to make this work with one single click ? (Setting a hotspot does not work, cause hotspots have the same problem.)
Regards,
TobiHello Tobias
The proposal by Naimesh is valid for CL_GUI_ALV_GRID, too. You may have a look at sample report ZUS_SDN_ALVGRID_EVENTS_HOTSPOT. Put the focus on any non-button cell and next click on any customer button.
*& Report ZUS_SDN_ALVGRID_EVENTS_HOTSPOT
*& Thread: Buttons in ALV Grid cell need focus to be clicked :-(
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1009251"></a>
REPORT zus_sdn_alvgrid_events_hotspot.
DATA:
gd_okcode TYPE ui_func,
gt_fcat TYPE lvc_t_fcat,
go_docking TYPE REF TO cl_gui_docking_container,
go_grid1 TYPE REF TO cl_gui_alv_grid.
DATA:
go_table TYPE REF TO cl_salv_table,
go_grid_adapter TYPE REF TO cl_salv_grid_adapter.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1.
PARAMETERS:
p_bukrs TYPE bukrs DEFAULT '2000' OBLIGATORY.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING
e_row_id
e_column_id
es_row_no
sender, " grid instance that raised the event
handle_button_click FOR EVENT button_click OF cl_gui_alv_grid
IMPORTING
es_col_id
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_hotspot_click.
* define local data
DATA:
ls_knb1 TYPE knb1,
ls_col_id TYPE lvc_s_col.
READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row_id-index.
CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
CASE e_column_id-fieldname.
WHEN 'KUNNR'.
SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
WHEN 'ERNAM'.
* SET PARAMETER ID 'USR' FIELD ls_knb1-ernam.
* NOTE: no parameter id available, yet simply show the priciple
CALL TRANSACTION 'SU01' AND SKIP FIRST SCREEN.
WHEN OTHERS.
* do nothing
ENDCASE.
* Set active cell to field BUKRS otherwise the focus is still on
* field KUNNR which will always raise event HOTSPOT_CLICK
ls_col_id-fieldname = 'BUKRS'.
CALL METHOD go_grid1->set_current_cell_via_id
EXPORTING
is_row_id = e_row_id
is_column_id = ls_col_id.
ENDMETHOD. "handle_hotspot_click
METHOD handle_button_click.
* define local data
DATA:
ls_knb1 TYPE knb1.
READ TABLE gt_knb1 INTO ls_knb1 INDEX es_row_no-row_id.
CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
ENDMETHOD. "handle_button_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = p_bukrs.
** TRY.
** CALL METHOD cl_salv_table=>factory
*** EXPORTING
*** LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE
*** R_CONTAINER =
*** CONTAINER_NAME =
** IMPORTING
** r_salv_table = go_table
** CHANGING
** t_table = gt_knb1.
** CATCH cx_salv_msg .
** ENDTRY.
** go_table->display( ).
** go_table->get_metadata( ).
** EXIT.
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Create ALV grid
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_docking
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Set event handler
SET HANDLER:
lcl_eventhandler=>handle_hotspot_click FOR go_grid1,
lcl_eventhandler=>handle_button_click FOR go_grid1.
* Build fieldcatalog and set hotspot for field KUNNR
PERFORM build_fieldcatalog_knb1.
* Display data
CALL METHOD go_grid1->set_table_for_first_display
CHANGING
it_outtab = gt_knb1
it_fieldcatalog = gt_fcat
EXCEPTIONS
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.
ENDIF.
* Link the docking container to the target dynpro
CALL METHOD go_docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
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.
ENDIF.
* ok-code field = GD_OKCODE
CALL SCREEN '0100'.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form BUILD_FIELDCATALOG_KNB1
* text
* --> p1 text
* <-- p2 text
FORM build_fieldcatalog_knb1 .
* define local data
DATA:
ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'KNB1'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT gt_fcat INTO ls_fcat
WHERE ( fieldname = 'KUNNR' OR
fieldname = 'ERNAM' OR
fieldname = 'BUKRS' ).
IF ( ls_fcat-fieldname = 'BUKRS' ).
ls_fcat-style = cl_gui_alv_grid=>mc_style_button.
" column appears as button
ELSEIF ( ls_fcat-fieldname = 'KUNNR' ).
ls_fcat-style = cl_gui_alv_grid=>mc_style_button.
ls_fcat-hotspot = abap_true.
ELSE.
ls_fcat-hotspot = abap_true.
ENDIF.
MODIFY gt_fcat FROM ls_fcat.
ENDLOOP.
ENDFORM. " BUILD_FIELDCATALOG_KNB1
Regards
Uwe -
Button in alv grid cell using REUSE_ALV_GRID_DISPLAY
Hi all,
I want to make the contents of 2 columns of my alv grid as push button with values as text on it. I am not using classes or methods but alv grid fm. On clicking the button one dialog box has to pop up which gives edit option for the values in that coloumn, my question is how to introduce button in alv grid cell? if i can use t_fieldcatalog-icon, then please give me the complete steps for that.
Thanks.this may helps u
u need to copy stadard screen elemetn to MARATAB1(at PF -STATUS)
You should copy the 'STANDARD' GUI status from program <b>SAPLSLVC_FULLSCREEN</b>
type this one in SE41 program name is:<b>SAPLSLVC_FULLSCREEN</b>
status : <b>STANDARD_FULLSCREEN</b>
and copy it ...
Type-pool
type-pools slis.
Tables
tables: mara,sscrfields.
Selection screen
select-options: s_matnr for mara-matnr.
PARAMETERS: p_email TYPE somlreci1-receiver.
TYPES: BEGIN OF t_charmara,
matnr(18) TYPE c, " Material Number
ernam(12) TYPE c, " Person Credited
aenam(12) TYPE c, " Person Changed Object
pstat(15) TYPE c, " Maintenance Status
END OF t_charmara.
Data Declarations
data: rt_extab type slis_t_extab, " Table of inactive function
codes
wa_charmara TYPE t_charmara, " work area of mara Table
fs_fieldcat type slis_t_fieldcat_alv,
" Field catalog with field
descriptions
t_fieldcat like line of fs_fieldcat,
" Table of Field catalog
r_ucomm like sy-ucomm, " User Command
rs_selfield TYPE slis_selfield. " cursor position ALV
data: filedlayout type slis_layout_alv,
heading type slis_t_listheader with header line,
t_event type slis_t_event.
data: fs_event like line of t_event.
data: fs_sort type slis_sortinfo_alv,
t_sort type slis_t_sortinfo_alv.
data: w_char(200) type c,
w_matnr type mara-matnr.
fs_sort-fieldname = 'MATNR'.
fs_sort-up = 'X'.
fs_sort-group = '*'.
append fs_sort to t_sort.
clear fS_sort.
DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
w_cnt TYPE i,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
Internal Tables
data: begin of it_mara occurs 0,
matnr like mara-matnr, " Material Number
ernam like mara-ernam, " Person Credited
aenam like mara-aenam, " Person Changed Object
pstat like mara-pstat, " Maintenance Status
end of it_mara.
DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
*at selection-screen on field event
AT SELECTION-SCREEN on s_matnr.
PERFORM f0100_VALIDATE_MATERIAL_NUMBER.
start-of-selection.
retrive Data from the data base table Mara
perform retrive_data_from_mara.
end-of-selection.
*Field catalog with field descriptions
perform fieldcat.
*perform top_of_page.
PERFORM EVENT_LIST.
*ALV Grid Display
perform alv_display.
Creating one Push button ENTER
perform maratab1 USING RT_EXTAB.
*& Form f0100_VALIDATE_MATERIAL_NUMBER
text
There are no interface parameters to be passed to this subroutine
FORM F0100_VALIDATE_MATERIAL_NUMBER .
select matnr " Material Number
from mara
up to 1 rows
into mara-matnr
where matnr in s_matnr.
endselect.
IF sy-subrc NE 0.
clear sscrfields-ucomm.
MESSAGE e000 WITH 'Enter valid Material number'(003).
ENDIF. " IF sy-subrc NE 0
ENDFORM. " f0100_VALIDATE_MATERIAL_NUMBER
*& Form retrive_data_from_mara
text
*There are no interface parameters to be passed to this subroutine
FORM retrive_data_from_mara .
select matnr " Material Number
ernam " Person Credited
aenam " Person Changed Object
pstat " Maintenance Status
from mara
into table It_mara
where matnr in s_matnr.
IF sy-subrc NE 0.
MESSAGE i001 WITH 'Records are not found'.
exit.
stop.
ENDIF. " IF sy-subrc NE 0
ENDFORM. " retrive_data_from_mara
*& Form fieldcat
text
*There are no interface parameters to be passed to this subroutine
FORM fieldcat .
*field catalog for MATNR
t_FIELDCAT-REF_TABNAME = 'MARA'.
t_fieldcat-fieldname = 'MATNR'.
t_fieldcat-col_pos = 1.
append t_fieldcat to fs_fieldcat.
clear t_fieldcat.
*field catalog for ERNAM
t_FIELDCAT-REF_TABNAME = 'MARA'.
t_fieldcat-fieldname = 'ERNAM'.
t_fieldcat-col_pos = 2.
append t_fieldcat to fs_fieldcat.
clear t_fieldcat.
*field catalog for AENAM
t_FIELDCAT-REF_TABNAME = 'MARA'.
t_fieldcat-fieldname = 'AENAM'.
t_fieldcat-col_pos = 3.
append t_fieldcat to fs_fieldcat.
clear t_fieldcat.
*field catalog for PSTAT
t_FIELDCAT-REF_TABNAME = 'MARA'.
t_fieldcat-fieldname = 'PSTAT'.
t_fieldcat-col_pos = 4.
append t_fieldcat to fs_fieldcat.
clear t_fieldcat.
ENDFORM. " fieldcat
*& Form EVENT_LIST
text
*There are no interface parameters to be passed to this subroutine
FORM EVENT_LIST .
fs_event-name ='TOP_OF_PAGE'.
fs_event-form = 'TOP_PAGE'.
append fs_event TO t_EVENT.
CLEAR FS_EVENT.
fs_event-name ='END_OF_PAGE'.
fs_event-form = 'END_PAGE'.
append fs_event TO t_EVENT.
CLEAR FS_EVENT.
fs_event-name ='END_OF_LIST'.
fs_event-form = 'LIST_END'.
append fs_event TO t_EVENT.
CLEAR FS_EVENT.
ENDFORM. " EVENT_LIST
*& Form alv_display
text
*There are no interface parameters to be passed to this subroutine
FORM alv_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'MARATAB1'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_STRUCTURE_NAME =
IS_LAYOUT =
IT_FIELDCAT = FS_FIELDCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT = T_SORT
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = T_EVENT
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IR_SALV_LIST_ADAPTER =
IT_EXCEPT_QINFO =
I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_MARA[]
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. " alv_display
form TOP_PAGE.
data:tbl_listheader type slis_t_listheader,
wa_listheader type slis_listheader .
wa_listheader-typ = 'S'.
wa_listheader-info = 'Created by : Vijay Pawar'.
append wa_listheader to tbl_listheader.
wa_listheader-typ = 'S'.
concatenate ' Date ' sy-datum into
wa_listheader-info separated by space.
append wa_listheader to tbl_listheader.
wa_listheader-typ = 'S'.
concatenate ' From ' s_matnr-low ' To ' s_matnr-high into
wa_listheader-info separated by space.
append wa_listheader to tbl_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = tbl_listheader
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM =
endform. " form TOP_PAGE.
form END_PAGE.
STATICS W_PAGE TYPE I .
data:tbl_listheader type slis_t_listheader,
wa_listheader type slis_listheader .
wa_listheader-typ = 'S'.
wa_listheader-info = W_PAGE.
append wa_listheader to tbl_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = tbl_listheader
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM =
add 1 to w_page.
endform. " form END_PAGE.
form list_end.
data:tbl_listheader type slis_t_listheader,
wa_listheader type slis_listheader .
wa_listheader-typ = 'S'.
wa_listheader-info = '......................................Last Page'
append wa_listheader to tbl_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = tbl_listheader
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM =
endform. " form list_end.
*& Form maratab1
text
-->P_RT_EXTAB text
FORM maratab1 USING P_RT_EXTAB.
SET PF-STATUS 'MARATAB1' EXCLUDING rt_extab.
ENDFORM. " maratab1
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
case r_ucomm.
when 'ENTER'.
perform bulid_xls_data_table.
PERFORM send_file_as_email_attachment
tables it_message
it_attach
using p_email "'[email protected]'
'Example .xls documnet attachment'
'XLS'
'filename'
changing gd_error
gd_reciever.
perform populate_email_message_body.
PERFORM initiate_mail_execute_program.
endcase. " case r_ucomm.
endform. " FORM user_command
perform populate_email_message_body.
PERFORM initiate_mail_execute_program.
CALL FUNCTION 'RH_START_EXCEL_WITH_DATA'
EXPORTING
DATA_FILENAME = 'MARA.XLS'
DATA_PATH_FLAG = 'W'
DATA_ENVIRONMENT =
DATA_TABLE = ITAB[]
MACRO_FILENAME =
MACRO_PATH_FLAG = 'E'
MACRO_ENVIRONMENT =
WAIT = 'X'
DELETE_FILE = 'X'
EXCEPTIONS
NO_BATCH = 1
EXCEL_NOT_INSTALLED = 2
INTERNAL_ERROR = 3
CANCELLED = 4
DOWNLOAD_ERROR = 5
NO_AUTHORITY = 6
FILE_NOT_DELETED = 7
OTHERS = 8
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
leave to list-processing.
endcase.
*& Form bulid_xls_data_table
text
*There are no interface parameters to be passed to this subroutine
FORM bulid_xls_data_table .
CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode
con_tab TYPE x VALUE '09'. "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
con_cret type c value cl_abap_char_utilities=>CR_LF.
CONCATENATE 'matnr' 'ernam' 'aenam' 'pstat'
INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
LOOP AT It_mara INTO wa_charmara.
CONCATENATE wa_charmara-matnr wa_charmara-ernam
wa_charmara-aenam wa_charmara-pstat
INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
ENDLOOP. " LOOP AT it_mara INTO...
ENDFORM. " bulid_xls_data_table
*& Form send_file_as_email_attachment
Send email
-->P_IT_MESSAGE text
-->P_IT_ATTACH text
-->P_P_EMAIL text
-->P_0387 text
-->P_0388 text
-->P_0389 text
-->P_0390 text
-->P_0391 text
-->P_0392 text
<--P_GD_ERROR text
<--P_GD_RECIEVER text
FORM send_file_as_email_attachment tables pit_message
pit_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = pit_attach[].
Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM. " send_file_as_email_attachment
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
Instructs mail send program for SAPCONNECT to send email.
FORM initiate_mail_execute_program.
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
*& Form POPULATE_EMAIL_MESSAGE_BODY
Populate message body text
form populate_email_message_body.
REFRESH it_message.
it_message = 'Please find attached a list test mara records'.
APPEND it_message.
endform. "form populate_email_message_bod
rewards if it helps u -
Problem with Excel output format
Hi Guys,
I am creating a report in XML Publisher (not standalone). I am facing some problems could anyone please help me to figure out the issues.
Is it possible to have all three output format (PDF, HTML & EXCEL) exact (same aligned) only by creating a single RTF Template? I am facing the problem with Excel output format the output format of excel is taking excels cell formatting.
Example Numeric fields --> Right Aligned, text fields --> Left Aligned
One more issue with excel is -ve(negative) values are getting displayed in red and in brackets like ($13) (with red color).
Our client want excel output on priority.
Is there any limitation for excel output format of reports?
It is very urgent for us please help.
Any help would be highly appreciated.
Thanks,
Pragati
Edited by: user11237443 on Aug 27, 2009 1:22 AMHi Mahi,
Thanks for your response. But i could not understand how can we write wrapper program could you please give some light on this or provide some link it would be helpful for me:-)
I have read that blog for excel limitations but i have more question?
1) What about the negative values?
if any field is displaying negative amount then excel not displaying right value for that:(
2)How can we align header or data?
Do XMLP with EBS provide any solution for formatting in excel?
3) If for the alignment of numeric value we concatenate them with any special character then how can we perform calculation that field?
Here are so many formatting issues do we need to write any code in xml for that?
Please help.
Many Thanks,
Pragati
Maybe you are looking for
-
HT1267 How do I delete an Apple account from my iphone
I have just got a reconditioned iphone as my original one broke. It has got an apple ID email address on it which isn't my own. How do I delete that account and add my own account to the phone.
-
Responsible Service Org and Service Team (partner function)
Hi all CRM gurus, I'm trying to understand the reasons behind the following design and I hope someone can clarify some points for me: 1. Organisation structure in CRM is set up with service organisation followed by service team, e.g. ABC Company |_Ca
-
Error loading Sample Basic in Essbase
Hi, Has anyone had this issue? I tried to load the data for Sample Basic DB in Essbase in a Windows Vista 32 pc and got this error msg: Database Basic loaded Database East loaded Database Xchgrate loaded Database Interntl loaded Unable to Connect to
-
Hi, i cant get my iphone to turn on after the wrong password was entered a number of times. Now it has just shut down. how can i get it working again?
-
Reference extending class name
I have a base class that instantiates a Logger object via: Logger.getLogger(this.getClass().getName()); When a class extends the base class the Logger still maintains the name of the base class. How do I initiate the Logger, in the base class, with t