ALV Report program linking 5 db tables.
What should be the general approach to generate a simple ALV program that links 5 database tables, where the selection criteria is date field?
Edited by: Matt on Dec 4, 2008 11:38 AM - Removed all caps
SAP Query is a bit of an abomination -- complicated to use correctly and definitely difficult to maintain.
If you need to get stuff from 5 different databases in one report it might be better from a Systems Performance perspective to create a "Z_object" containing the data you want and then simply run your ABAP ALV against your "Z_Object".
Depending on the frequency / content of your report you could run say a batch job every evening to update your "Z_Object".
The other possibility would be to run your query on a BW/BI system if the volume of data is quite large -- however if you don't have BW then OK this is not a possible solution.
My preference would be to go for the "Z-Object".
I also have to wonder at how the original application was designed if you really do need to collect data from 5 different data bases --perhaps you should re-design the original application.
Cheers
jimbo.
Similar Messages
-
Insert records from report program into R3 table
Hi
I wanted to insert records from report program into R3 table.
here is my code
data : itab type standard table of zemp initial size 10 with header line.
itab-EMPNO = '012'.
itab-ENAME = 'XXXX'.
itab-JOB = 'XXXX'.
APPEND itab.
insert ztable from table itab.
but i am getting the following error
the type of the data base table and work area/internal table "ITAB" are no unicode-converible.
how can I insert records from report program into R3 table
should I have to write move corresponding
pls guide
thanks
manianHi,
itab-EMPNO = '012'.
itab-ENAME = 'XXXX'.
itab-JOB = 'XXXX'.
APPEND itab.
insert ztable from table itab.
Do one thing
Data : itab type table of ztable with header line.
itab-EMPNO = '012'.
itab-ENAME = 'XXXX'.
itab-JOB = 'XXXX'.
APPEND itab.
insert ztable from table itab.
error will resolve, then try to make structure similar to ZTABLE -
Calling a ALV Report program via a Remote Function module.
H All,
The thing which I am looking out for is ,to know a technique to acheive this,
To start with,
For the transaction MB51-(Material Document List),which is a Report Program "RM07DOCS",I also observed that this uses a ALV to display the output.
Now what I actually require is another extra field (from MARA table ) along with the standard output that is displayed from this report.
Also this needs to be passed to a different UI system(build using VC ).
So I have a RFC eg DisplayList(),where in I need to exeucte this report program ,get the output what it gives ,add my additional information what I want to and pass it as a export parameter,
So this is the structure which I can visualise,
FUNCTION ZFUN_MB51TXN.
I would get all the import parameters here ,from who ever is calling my fun module,
*Call the report program,pass the input parameters required
*get the output from this report program
*send the output to the caller through export parameters
ENDFUNCTION.
So Here I need to know ,Can this be achieved something using Submit report or anything,Any guidelines to move further would be really of great help!Hi All,
It would really be great if you can explain with the reference to the same report program,the same selection screen elemetns or something.
Thanks,
Archies! -
Hi Experts
I have created one report program and display the report in the ALV using FM Reuse alv grid
Now i want to handle double click on one of the field to navigate to different transaction .
Please help me in this regard .. also i am not creating any container using classes .
Regards
HIteshHi,
Refer this program for interactive alv.
REPORT ZSAMPLE.
TYPE-POOLS:SLIS.
TABLES:MARA, MAKT.
DATA: MYDATE(10).
TYPES:BEGIN OF TY_MARA,
MATNR TYPE MATNR,
ERSDA TYPE ERSDA,
ERNAM TYPE ERNAM,
LAEDA TYPE LAEDA,
END OF TY_MARA.
TYPES:BEGIN OF TY_MAKT,
MATNR TYPE MATNR,
MAKTX TYPE MAKTX,
MAKTG TYPE MAKTG,
END OF TY_MAKT.
DATA:IT_MARA TYPE TABLE OF TY_MARA,
WA_MARA TYPE TY_MARA.
DATA:IT_MAKT TYPE TABLE OF TY_MAKT,
WA_MAKT TYPE TY_MAKT.
DATA : IT_FIELDCAT_MARA TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT_MARA TYPE SLIS_FIELDCAT_ALV.
DATA : IT_FIELDCAT_MAKT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT_MAKT TYPE SLIS_FIELDCAT_ALV.
DATA: I_EVENT TYPE SLIS_T_EVENT ,
W_EVENT TYPE SLIS_ALV_EVENT,
I_LISTHEADER TYPE SLIS_T_LISTHEADER,
W_LISTHEADER TYPE SLIS_LISTHEADER,
W_END TYPE SLIS_LISTHEADER,
I_END TYPE SLIS_T_LISTHEADER.
DATA:I_EXCLUDING TYPE SLIS_T_EXTAB,
W_EXCLUDING TYPE SLIS_EXTAB.
CONCATENATE SY-DATUM6(2) '/' SY-DATUM4(2) '/' SY-DATUM+0(4) INTO MYDATE .
CONSTANTS: C_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
C_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_LIST',
C_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.
SELECTION-SCREEN:BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:MATERIAL FOR MARA-MATNR.
SELECTION-SCREEN:END OF BLOCK B1.
START-OF-SELECTION.
PERFORM READ_DATA.
PERFORM FIELDCAT.
*PERFORM TOP-OF-PAGE.
*PERFORM END-OF-PAGE.
PERFORM EVENTS_GET USING I_EVENT.
*PERFORM TOP-OF-PAGE.
*PERFORM END-OF-PAGE.
PERFORM DISPLAY.
*& Form READ_DATA
text
--> p1 text
<-- p2 text
FORM READ_DATA .
SELECT MATNR ERSDA ERNAM LAEDA FROM MARA INTO CORRESPONDING FIELDS OF TABLE IT_MARA WHERE MATNR IN MATERIAL.
ENDFORM. " READ_DATA
*& Form FIELDCAT
text
--> p1 text
<-- p2 text
FORM FIELDCAT .
WA_FIELDCAT_MARA-FIELDNAME = 'MATNR'.
WA_FIELDCAT_MARA-TABNAME = 'IT_MARA'.
WA_FIELDCAT_MARA-emphasize = 'X'.
APPEND WA_FIELDCAT_MARA TO IT_FIELDCAT_MARA.
CLEAR WA_FIELDCAT_MARA.
WA_FIELDCAT_MARA-FIELDNAME = 'ERSDA'.
WA_FIELDCAT_MARA-TABNAME = 'IT_MARA'.
APPEND WA_FIELDCAT_MARA TO IT_FIELDCAT_MARA.
CLEAR WA_FIELDCAT_MARA.
WA_FIELDCAT_MARA-FIELDNAME = 'ERNAM'.
WA_FIELDCAT_MARA-TABNAME = 'IT_MARA'.
APPEND WA_FIELDCAT_MARA TO IT_FIELDCAT_MARA.
CLEAR WA_FIELDCAT_MARA.
WA_FIELDCAT_MARA-FIELDNAME = 'LAEDA'.
WA_FIELDCAT_MARA-TABNAME = 'IT_MARA'.
APPEND WA_FIELDCAT_MARA TO IT_FIELDCAT_MARA.
CLEAR WA_FIELDCAT_MARA.
ENDFORM. " FIELDCAT
*& Form DISPLAY
text
--> p1 text
<-- p2 text
FORM DISPLAY .
W_EXCLUDING-FCODE = '&ETA'.
APPEND W_EXCLUDING TO I_EXCLUDING.
W_EXCLUDING-FCODE = '&OUP'.
APPEND W_EXCLUDING TO I_EXCLUDING.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE'
I_GRID_TITLE = 'MARA DETAILS'
IT_FIELDCAT = IT_FIELDCAT_MARA
IT_EXCLUDING = I_EXCLUDING
IT_EVENTS = I_EVENT
TABLES
T_OUTTAB = IT_MARA[]
ENDFORM. " DISPLAY
FORM USER_COMMAND USING USER_COMMAND LIKE SY-UCOMM USR TYPE SLIS_SELFIELD.
refresh it_makt.
SELECT * FROM MAKT INTO CORRESPONDING FIELDS OF TABLE IT_MAKT WHERE MATNR = USR-VALUE.
PERFORM FIELDCAT1.
PERFORM DISPLAY1.
ENDFORM.
*& Form FIELDCAT1
text
--> p1 text
<-- p2 text
FORM FIELDCAT1 .
clear it_fieldcat_makt[].
WA_FIELDCAT_MAKT-FIELDNAME = 'MATNR'.
WA_FIELDCAT_MAKT-TABNAME = 'IT_MAKT'.
APPEND WA_FIELDCAT_MAKT TO IT_FIELDCAT_MAKT.
CLEAR WA_FIELDCAT_MAKT.
WA_FIELDCAT_MAKT-FIELDNAME = 'MAKTX'.
WA_FIELDCAT_MAKT-TABNAME = 'IT_MAKT'.
APPEND WA_FIELDCAT_MAKT TO IT_FIELDCAT_MAKT.
CLEAR WA_FIELDCAT_MAKT.
WA_FIELDCAT_MAKT-FIELDNAME = 'MAKTG'.
WA_FIELDCAT_MAKT-TABNAME = 'IT_MAKT'.
APPEND WA_FIELDCAT_MAKT TO IT_FIELDCAT_MAKT.
CLEAR WA_FIELDCAT_MAKT.
ENDFORM. " FIELDCAT1
*& Form DISPLAY1
text
--> p1 text
<-- p2 text
FORM DISPLAY1 .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = IT_FIELDCAT_MAKT
TABLES
T_OUTTAB = IT_MAKT
ENDFORM. " DISPLAY1
*& Form TOP-OF-PAGE
text
--> p1 text
<-- p2 text
FORM TOP_OF_PAGE .
CLEAR I_LISTHEADER.
W_LISTHEADER-TYP = 'H'.
W_LISTHEADER-INFO = 'MATERIALS DOCUMENT'.
APPEND W_LISTHEADER TO I_LISTHEADER.
CLEAR W_LISTHEADER.
W_LISTHEADER-TYP = 'S'.
W_LISTHEADER-KEY = 'DATE:'.
W_LISTHEADER-INFO = MYDATE.
APPEND W_LISTHEADER TO I_LISTHEADER.
CLEAR W_LISTHEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = I_LISTHEADER
I_LOGO = 'ENJOYSAP_LOGO'
I_END_OF_LIST_GRID =
I_ALV_FORM = 'X'
ENDFORM. " TOP-OF-PAGE
*& Form EVENTS_GET
text
--> p1 text
<-- p2 text
FORM EVENTS_GET USING P_I_EVENT TYPE SLIS_T_EVENT..
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 4
IMPORTING
ET_EVENTS = P_I_EVENT
EXCEPTIONS
LIST_TYPE_WRONG = 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. " EVENTS_GET
READ TABLE P_I_EVENT WITH KEY NAME = SLIS_EV_TOP_OF_PAGE INTO W_EVENT.
IF SY-SUBRC = 0.
MOVE C_TOP_OF_PAGE TO W_EVENT-FORM.
APPEND W_EVENT TO I_EVENT.
ENDIF.
READ TABLE P_I_EVENT WITH KEY NAME = SLIS_EV_END_OF_LIST INTO W_EVENT.
IF SY-SUBRC = 0.
MOVE C_END_OF_PAGE TO W_EVENT-FORM.
APPEND W_EVENT TO I_EVENT.
ENDIF.
READ TABLE P_I_EVENT WITH KEY NAME = SLIS_EV_USER_COMMAND INTO W_EVENT.
IF SY-SUBRC = 0.
MOVE C_USER_COMMAND TO W_EVENT-FORM.
APPEND W_EVENT TO I_EVENT.
ENDIF.
ENDFORM. " events_get
*& Form END-OF-PAGE
text
--> p1 text
<-- p2 text
FORM END_OF_LIST .
W_END-TYP = 'S'.
W_END-INFO = 'END-OF-PAGE'.
APPEND W_END TO I_END.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = I_END
I_LOGO = 'ENJOYSAP_LOGO'
I_END_OF_LIST_GRID =
I_ALV_FORM = 'X'
ENDFORM. " END-OF-PAGE
Please reward points if helpful -
How to get total in ALV report in same Internal table?
Data : Begin of it_data,
kunnr type kunnr,
name1 type name1,
amt1 type btrt01, " CURR 15,2
end of it_data.
loop at it_data into wa_data
endloop.
Hello friends,
I am developing one ALV report with 20 rows.
I have filled one internal table with some fileds like amount.
I want to get total of all amount1 in AMT1 field.
So, How to get total of amount in same internal table in ALV report ?
It is ok if i get duplicate rows in internal table.
Points 'll be awarded soon.
Regards,
NVMHi Ronny,
the alv output will display the sum at the last row.
for this functionality u have do this logic.
data: lw_fcat type slis_fieldcat_alv.
data: lt_fcat type slis_t_fieldcat_alv/
wa_fcat-fieldname = 'AMT1'.
wa_fcat-tabname = 'ITAB'.
wa_fcat-do_sum = 'X'.
append wa_fcat to lt_fcat.
and then pass it to reuse_alv_grid_display function,
regards,
Santosh Thorat -
Trigger report program if Z table field is modified/created
Hi,
I have a requirement where i want to run the report program ONLY if a particular field ( Dispatch date ) is modified or updated of a 'Z' Table ( Custom Table ).
The report program would fetch data from the same 'Z' table only for those records which are modified/updated. This data is then transferred to an application server.
1. How should i trigger the report program for the above requirement.
2. If a background program is to be created, then what should be the trigerring criteria & where it should be defined.
3. Do i need to set any change pointers etc.
Pointers to the above requirement would be very helpful.
Thanks in advance,
Best regards,
Prashanthi prashant,
i'm working on a similar query as that of ur's.
see the logic is as we proceed in ur case is DISPATCH DATE say are to be modified in the process of inserting 0r changing the contents of a ZTABLE.
so here the logic would be
loop at itab.
MODIFY ZTABLE FROM TABLE ITAB.
endloop.
This is the key reference in our logic .
now it is known that u have a ZTABLE with dispatch date
here the data element will be DATUM .
now in the ZTABLE go to DISPATCH DATE filed i.e its DATA ELEMET double click on data element DATUM .
now if u see here there will be a tick called as Checkbox on change document which is enabling the CDHDR and CDPOS.
*if its not checked get it checked in .
This is the source to the logic.
now what u need to do in ur logic part is
1. collect all the entries of the table.
(im not sure how many entries are there but try to get all the primary keys + one or two more fields so that the time is saved . this we do to check.
2. before the modify comes into affect see if u can store all the content of the table i.e step 1.
3.lets say we have modified the ZTABLE.
4.now collect all the entries i.e newly modified into new inttab with same logic as the basic primary key configurations + two fields .
5. let the two internal tables be compared and based on the comparision derive a new internal table as follows .
REPORT ztemp .
TYPES: BEGIN OF line,
brand(10) TYPE c,
rate(3) TYPE p DECIMALS 2,
gender(1) TYPE c,
sno TYPE i,
desc(30) TYPE c,
END OF line.
DATA: it_lines_1 TYPE TABLE OF line
WITH KEY brand
rate
gender,
wa_lines_1 LIKE LINE OF it_lines_1.
DATA: it_lines_2 TYPE TABLE OF line
WITH KEY brand
rate
gender,
wa_lines_2 LIKE LINE OF it_lines_2.
DATA: gi_counter TYPE i.
START-OF-SELECTION.
PERFORM fill_it_line_1. " not included; tested with your 4 records
SORT it_lines_1.
CLEAR gi_counter.
LOOP AT it_lines_1 INTO wa_lines_1.
wa_lines_2 = wa_lines_1.
ADD 1 TO gi_counter.
AT END OF gender.
IF gi_counter > 1.
APPEND wa_lines_2 TO it_lines_2.
ENDIF.
CLEAR gi_counter.
ENDAT.
ENDLOOP.
This only works if you are able to define the fields of the internal table in this order, so with the key fields first in the right order. Otherwise the AT END OF will not work.
6. now if u can reach upto here then we need not create a background program .
7. u are exactly right change pointers will have to come into picture .
8 .then comes the picture of moving this content to application server using datasets etc.
hope this helps u in building the logic .
i would like to hear from other developers too in this regard.
Thanks and regards,
vijay. -
Help need on ALV Report Program
Hi all.....
im facing problem in the following code....it shows 'No records found' (as same as my coding generated)whenever i give wrong vendor no:(lifnr), but if i gives the correct one(as in table lfa1)...it shows Runtime error as <b>"the occupied line length in the program text must not exceed the width of the internal table"</b>..
pls verify...
just go thru my code and revert me the feedback of what i did wrong and pls i dont want any example codes from u guys since i've seen so much and couldnt solve it with that...
hope u understand......what i need
Rewards based on the above reuirements....only
*******************************CODING***********************************************
REPORT ZALV_MERGE.
TABLES:lfa1.
DATA:BEGIN OF itab OCCURS 100,
lifnr LIKE lfa1-lifnr,
land1 LIKE lfa1-land1,
name1 LIKE lfa1-name1,
ort01 LIKE lfa1-ort01,
regio LIKE lfa1-regio,
sortl LIKE lfa1-sortl,
END OF itab.
data: i_repid like sy-repid,
i_tabix like sy-tabix.
TYPE-POOLS: slis.
DATA: fcat TYPE slis_t_fieldcat_alv.
SELECT-OPTIONS: LIFNR FOR LFA1-LIFNR.
SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE itab WHERE lifnr IN LIFNR.
clear i_tabix.
describe table itab lines i_tabix.
if i_tabix lt 1.
write:/ 'No materials found'.
exit.
endif.
i_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = i_repid
I_INTERNAL_TABNAME = 'ITAB'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = I_REPID
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = 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.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = i_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME = 'ITAB'
IS_LAYOUT =
IT_FIELDCAT = fcat
I_SAVE = 'A'
TABLES
T_OUTTAB = ITAB
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.Hi,
think inthis program in the function module REUSE_ALV_FIELDCATALOG_MERGE
in exporting parameter you are using -->
I_INTERNAL_TABNAME = <itab_name>
this <itab_name> is not like any physical structure .So make a structure through SE11 like <itab_name>.
u have to create a structure in SE11 with the fields, and then pass that structure into the REUSE_ALV_FIELDCATALOG_MERGE , in the parameter
I_internal_tabname = ' structure name '.
even though u create a structure, u need to pass it to the table parameter.
then it will work.
Otherwise manually build the fieldcatalog.
find the following code as an example.
DATA : l_pos TYPE i VALUE 1.
ist_fieldcat-fieldname = 'POSID'.
ist_fieldcat-tabname = 'IT_FINAL'.
ist_fieldcat-outputlen = 24.
ist_fieldcat-col_pos = l_pos.
ist_fieldcat-ddictxt = 'L'.
ist_fieldcat-key = 'X'.
ist_fieldcat-seltext_l = 'Appropriation Request Number'.
APPEND ist_fieldcat.
CLEAR ist_fieldcat.
l_pos = l_pos + 1.
ist_fieldcat-fieldname = 'TXT04'.
ist_fieldcat-tabname = 'IT_FINAL'.
ist_fieldcat-outputlen = 4.
ist_fieldcat-col_pos = l_pos.
ist_fieldcat-ddictxt = 'L'.
ist_fieldcat-key = 'X'.
ist_fieldcat-seltext_l = 'Status'.
ist_fieldcat-EMPHASIZE = 'C400'.
APPEND ist_fieldcat.
CLEAR ist_fieldcat.
l_pos = l_pos + 1.
ist_fieldcat-fieldname = 'UDATE'.
ist_fieldcat-tabname = 'IT_FINAL'.
ist_fieldcat-outputlen = 8.
ist_fieldcat-col_pos = l_pos.
ist_fieldcat-ddictxt = 'L'.
ist_fieldcat-key = 'X'.
ist_fieldcat-seltext_l = 'Status Date'.
IST_FIELDCAT-EMPHASIZE = 'C600'.
APPEND ist_fieldcat.
CLEAR ist_fieldcat.
<i><b>Reward point if find helpful
Debjani</b></i> -
HI I AM NEW TO ABAP..CAN ANYONE PROVIDE WITH A STEP BY STEP GUIDE TO ALV PROGRAMMING AND MODULE POOL PROGRAMMING
Hi,
Please check this PDF documents.
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/CAGTFLV/CAGTFLV.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf
Hope this will help to start with.
Regards,
Ferry Lianto
Please reward points if helpful. -
Get ALV Report's Result Into Internal Table
Hello everyone,
is there a way to get a alv reports result into an internal table?
For example: is it possible to get the values from transaction S_ALR_87012078.
I mean i want to write a function an it will give you the alv reports result as internal table, so you won't have to dig the reports code in.
thanks to any answers from now. bye.Hi
This is a wrapper program which will execute the standard program and capture the output as we are using list to memory
Then after we will be using LIST_FROM_MEMORY and 'LIST_TO_ASCI'
submit rhrhaz00 exporting list to memory
and return
with pchplvar = pchplvar
with pchotype = pchotype
with pchobjid in pchobjid
with pchsobid in pchsobid
with pchseark = pchseark
with pchostat = pchostat
with pchistat = pchistat
with pchztr_d = pchztr_d
with pchztr_a = pchztr_a
with pchztr_z = pchztr_z
with pchztr_m = pchztr_m
with pchztr_p = pchztr_p
with pchztr_y = pchztr_y
with pchztr_f = pchztr_f
with pchobeg = pchobeg
with pchoend = pchoend
with pchtimed = pchtimed
with pchbegda = pchbegda
with pchendda = pchendda
* with pchwegid = pchwegid
* with pchsvect = pchsvect
* with pchdepth = pchdepth
with infty in infty
with subty in subty
with vdata = vdata
with info = info.
data: list like abaplist occurs 0 with header line.
data: txtlines(1024) type c occurs 0 with header line.
clear list.
refresh list.
clear tbl_reportlines.
refresh tbl_reportlines.
call function 'LIST_FROM_MEMORY'
tables
listobject = list
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.
call function 'LIST_TO_ASCI'
* EXPORTING
* LIST_INDEX = -1
* WITH_LINE_BREAK = ' '
* IMPORTING
* LIST_STRING_ASCII =
* LIST_DYN_ASCII =
tables
listasci = txtlines
listobject = list
exceptions
empty_list = 1
list_index_invalid = 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.
else.
tbl_reportlines[] = txtlines[].
call function 'LIST_FREE_MEMORY'.
endif.
Here is the simple example program
*Example Code (Retrieving list from memory)
DATA BEGIN OF itab_list OCCURS 0.
INCLUDE STRUCTURE abaplist.
DATA END OF itab_list.
DATA: BEGIN OF vlist OCCURS 0,
filler1(01) TYPE c,
field1(06) TYPE c,
filler(08) TYPE c,
field2(10) TYPE c,
filler3(01) TYPE c,
field3(10) TYPE c,
filler4(01) TYPE c,
field4(3) TYPE c,
filler5(02) TYPE c,
field5(15) TYPE c,
filler6(02) TYPE c,
field6(30) TYPE c,
filler7(43) TYPE c,
field7(10) TYPE c,
END OF vlist.
SUBMIT zreport EXPORTING LIST TO MEMORY.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = itab_list
EXCEPTIONS
not_found = 4
OTHERS = 8.
CALL FUNCTION 'LIST_TO_ASCI'
EXPORTING
list_index = -1
TABLES
listasci = vlist
listobject = itab_list
EXCEPTIONS
empty_list = 1
list_index_invalid = 2
OTHERS = 3.
IF sy-subrc NE '0'.
WRITE:/ 'LIST_TO_ASCI error !! ', sy-subrc.
ENDIF.
Re: alv to internal table -
Slow response of ALV report for a high volume internal table
We have a requirement in which we have to display more than 5 lac records (= 500,000) in a single alv report. The internal table has 30 fields. it takes around five minutes to display the alv.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_repid
i_callback_pf_status_set = pfstatus
it_fieldcat = it_fcat[]
i_save = 'A'
is_layout = gs_layout
is_variant = import_variant
it_events = events[]
TABLES
t_outtab = i_tab.
above is the code used to display the alv. Any change in the coding to be done to improve the performance?
Thanks in advance.
K Mohan
Edited by: Thomas Zloch on May 23, 2011 4:16 PMHi,
As Thomas said ALV is not designed to display such a huge data, any how you can limit the data in the selection screen. one more reason is if you display 5Lak records in one ALV list then if you download them to excel sheet, you can download upto 65000 records only. So limit the display not more than 60000 for a better performance.
Thanks,
Bhargav. -
Hi frnds,
I want to write an alv report program using oops concepts.CAn anybody send me a simple code to generate an alv reports?
Thanks a lot in advance.Hi
http://www.sapdev.co.uk/reporting/alv/alvobjgrid/alvobject_sort.htm
*& Report ZLCL_ALV_INVOICE *
REPORT ZLCL_ALV_INVOICE .
TABLES: VBRK.
DATA: ITAB LIKE VBRP OCCURS 1 WITH HEADER LINE.
DATA: O_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
O_GRID TYPE REF TO CL_GUI_ALV_GRID.
START-OF-SELECTION.
SET SCREEN 100.
*& Form GET_DATA
text
FORM GET_DATA .
SELECT *
FROM VBRP
INTO TABLE ITAB
WHERE VBELN = VBRK-VBELN.
ENDFORM. " GET_DATA
*& Module STATUS_0100 OUTPUT
text
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MENU'.
IF O_CONT IS INITIAL.
CREATE OBJECT O_CONT
EXPORTING
CONTAINER_NAME = 'INV_CONT' "Screen custom control name
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
OTHERS = 6
IF SY-SUBRC <> 0.
MESSAGE I000(Z00) WITH 'Error in custom container'.
EXIT.
ENDIF.
CREATE OBJECT O_GRID
EXPORTING
I_PARENT = O_CONT "Custom container class object
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE I000(Z00) WITH 'Error in alv grid linking'.
EXIT.
ENDIF.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Module SHOW_ALV_GRID INPUT
text
MODULE SHOW_ALV_GRID INPUT.
PERFORM GET_DATA.
CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'VBRP'
CHANGING
IT_OUTTAB = ITAB[]
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
MESSAGE I000(Z00) WITH 'Error in showing alv grid'.
EXIT.
ENDIF.
ENDMODULE. " SHOW_ALV_GRID INPUT
you can understand very easily -
Adding color to few rows in ALV report output
Hi,
I have developed a ALV report program which displays the project details of the employees.In the output the rows containing the employees who have been part of the project should be displayed in different color.I have used necessary code for this but still the rows are not displayed in different color.
Given below is my program.Please suggest me possible solution for this.
REPORT ZPROJ_ALL_DETAILS.
TYPE-POOLS: SLIS.
Tables: zheempl,zhealoc,zheproj,zheskil.
types: begin of ty_zheempl,
empid like zheempl-empid,
grade like zheempl-grade,
location like zheempl-location,
pu like zheempl-pu,
name1 like zheempl-name1,
end of ty_zheempl.
types: begin of ty_zhealoc,
project like zhealoc-project,
stdat like zhealoc-stdat,
endat like zhealoc-endat,
role like zhealoc-role,
end of ty_zhealoc.
types: begin of ty_output,
empid like zheempl-empid,
grade like zheempl-grade,
location like zheempl-location,
pu like zheempl-pu,
name1 like zheempl-name1,
role like zhealoc-role,
stdat like zhealoc-stdat,
endat like zhealoc-endat,
cellcolor(4) type c,
end of ty_output.
data: t_zheempl type standard table of ty_zheempl,
t_zhealoc type standard table of ty_zhealoc,
t_output type standard table of ty_output with header line.
data: wa_zheempl type ty_zheempl,
wa_zhealoc type ty_zhealoc,
wa_output type ty_output.
DATA : T_FIELDCAT TYPE slis_t_fieldcat_alv.
Data : wa_fieldcat type slis_fieldcat_alv.
Data: it_top TYPE slis_t_listheader,
wa_top TYPE slis_listheader.
Data: t_cellcolor TYPE lvc_t_scol WITH HEADER LINE,
wa_cellcolor TYPE lvc_s_scol.
Data: t_layout TYPE slis_layout_alv.
*selection-screen
selection-screen: begin of block b1 with frame title text-001.
select-options: s_proj for wa_zhealoc-project,
s_empid for wa_zheempl-empid.
parameters: p_date like sy-datum obligatory.
selection-screen: end of block b1.
selection-screen: begin of block b2 with frame title text-002.
parameters: p_prtosr radiobutton group g1 default 'X',
p_prusly radiobutton group g1.
selection-screen: end of block b2.
selection-screen: begin of block b3 with frame title text-003.
parameters: p_dwtodk as checkbox default 'X'.
selection-screen: end of block b3.
selection-screen: begin of block b4 with frame title text-004.
parameters: p_shwhis as checkbox default 'X'.
selection-screen: end of block b4.
Start-of-selection
IF p_shwhis = 'X'.
SELECT l~empid
l~grade
l~location
l~pu
l~name1
c~role
c~stdat
c~endat
INTO TABLE t_output
FROM ( zheempl AS l
INNER JOIN zhealoc
AS c ON lempid = cempid )
where project IN s_proj
AND endat < p_date
OR endat > p_date.
t_output-cellcolor = 'C310'.
MODIFY t_output transporting cellcolor where endat < p_date.
ELSE.
select l~empid
l~grade
l~location
l~pu
l~name1
c~role
c~stdat
c~endat
INTO TABLE t_output
FROM ( zheempl AS l
INNER JOIN zhealoc
AS c ON lempid = cempid )
WHERE project in s_proj
AND endat > p_date.
ENDIF.
wa_fieldcat-col_pos = '1'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'EMPID'.
wa_fieldcat-seltext_m = 'Employee ID'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '2'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'NAME1'.
wa_fieldcat-seltext_m = 'Name 1'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '3'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'ROLE'.
wa_fieldcat-seltext_m = 'Role of employee in the project'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '4'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'STDAT'.
wa_fieldcat-seltext_m = 'Start Date'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '5'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'ENDAT'.
wa_fieldcat-seltext_m = 'End Date'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '6'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'GRADE'.
wa_fieldcat-seltext_m = 'Salary Level'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '7'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'PU'.
wa_fieldcat-seltext_m = 'Department Number'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '8'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'LOCATION'.
wa_fieldcat-seltext_m = 'Work Location'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
t_layout-no_input = 'X'.
t_layout-colwidth_optimize = 'x'.
t_layout-info_fieldname = 'LINE_COLOR'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
i_callback_top_of_page = 'TOP'
is_layout = t_layout
IT_FIELDCAT = T_FIELDCAT
i_save = 'X'
TABLES
t_outtab = T_OUTPUT
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.
Form top.
Refresh it_top.
wa_top-typ = 'S'.
wa_top-key = 'Requestor'.
wa_top-info = sy-uname.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'S'.
wa_top-key = 'Program'.
wa_top-info = sy-repid.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'S'.
wa_top-key = 'Page'.
wa_top-info = sy-pagno.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'S'.
wa_top-key = 'Date'.
wa_top-info = sy-datum.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'H'.
wa_top-info = 'Project Details'.
APPEND wa_top to it_top.
CLEAR wa_top.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_top.
ENDFORM.{ REPORT ZPROJ_ALL_DETAILS.
TYPE-POOLS: SLIS.
Tables: zheempl,zhealoc,zheproj,zheskil.
types: begin of ty_zheempl,
empid like zheempl-empid,
grade like zheempl-grade,
location like zheempl-location,
pu like zheempl-pu,
name1 like zheempl-name1,
end of ty_zheempl.
types: begin of ty_zhealoc,
project like zhealoc-project,
stdat like zhealoc-stdat,
endat like zhealoc-endat,
role like zhealoc-role,
end of ty_zhealoc.
types: begin of ty_output,
empid like zheempl-empid,
grade like zheempl-grade,
location like zheempl-location,
pu like zheempl-pu,
name1 like zheempl-name1,
role like zhealoc-role,
stdat like zhealoc-stdat,
endat like zhealoc-endat,
cellcolor(4) type c,
end of ty_output.
data: t_zheempl type standard table of ty_zheempl,
t_zhealoc type standard table of ty_zhealoc,
t_output type standard table of ty_output with header line,
t_output1 type standard table of ty_output with header line.
data: wa_zheempl type ty_zheempl,
wa_zhealoc type ty_zhealoc,
wa_output type ty_output,
wa_output1 type ty_output.
DATA : T_FIELDCAT TYPE slis_t_fieldcat_alv.
Data : wa_fieldcat type slis_fieldcat_alv.
Data: it_top TYPE slis_t_listheader,
wa_top TYPE slis_listheader.
Data: t_cellcolor TYPE lvc_t_scol WITH HEADER LINE,
wa_cellcolor TYPE lvc_s_scol.
Data: t_layout TYPE slis_layout_alv.
*selection-screen
selection-screen: begin of block b1 with frame title text-001.
select-options: s_proj for wa_zhealoc-project,
s_empid for wa_zheempl-empid.
parameters: p_date like sy-datum obligatory.
selection-screen: end of block b1.
selection-screen: begin of block b2 with frame title text-002.
parameters: p_prtosr radiobutton group g1 default 'X',
p_prusly radiobutton group g1.
selection-screen: end of block b2.
selection-screen: begin of block b3 with frame title text-003.
parameters: p_dwtodk as checkbox default 'X'.
selection-screen: end of block b3.
selection-screen: begin of block b4 with frame title text-004.
parameters: p_shwhis as checkbox default 'X'.
selection-screen: end of block b4.
Start-of-selection
IF p_shwhis = 'X'.
SELECT l~empid
l~grade
l~location
l~pu
l~name1
c~role
c~stdat
c~endat
INTO TABLE t_output
FROM ( zheempl AS l
INNER JOIN zhealoc
AS c ON lempid = cempid )
where project IN s_proj
AND endat < p_date
OR endat > p_date.
t_output-cellcolor = 'C310'.
MODIFY t_output transporting cellcolor where endat < p_date.
ELSE.
select l~empid
l~grade
l~location
l~pu
l~name1
c~role
c~stdat
c~endat
INTO TABLE t_output
FROM ( zheempl AS l
INNER JOIN zhealoc
AS c ON lempid = cempid )
WHERE project in s_proj
AND endat > p_date.
ENDIF.
wa_fieldcat-col_pos = '1'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'EMPID'.
wa_fieldcat-seltext_m = 'Employee ID'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '2'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'NAME1'.
wa_fieldcat-seltext_m = 'Name 1'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '3'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'ROLE'.
wa_fieldcat-seltext_m = 'Role of employee in the project'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '4'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'STDAT'.
wa_fieldcat-seltext_m = 'Start Date'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '5'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'ENDAT'.
wa_fieldcat-seltext_m = 'End Date'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '6'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'GRADE'.
wa_fieldcat-seltext_m = 'Salary Level'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '7'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'PU'.
wa_fieldcat-seltext_m = 'Department Number'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '8'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'LOCATION'.
wa_fieldcat-seltext_m = 'Work Location'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
t_layout-no_input = 'X'.
t_layout-colwidth_optimize = 'x'.
t_layout-info_fieldname = 'LINE_COLOR'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
i_callback_top_of_page = 'TOP'
is_layout = t_layout
IT_FIELDCAT = T_FIELDCAT
i_save = 'X'
TABLES
t_outtab = T_OUTPUT
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.
Form top.
Refresh it_top.
wa_top-typ = 'S'.
wa_top-key = 'Requestor'.
wa_top-info = sy-uname.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'S'.
wa_top-key = 'Program'.
wa_top-info = sy-repid.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'S'.
wa_top-key = 'Page'.
wa_top-info = sy-pagno.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'S'.
wa_top-key = 'Date'.
wa_top-info = sy-datum.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'H'.
wa_top-info = 'Project Details'.
APPEND wa_top to it_top.
CLEAR wa_top.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_top.
ENDFORM.} -
Problem in ALV report o/p to Excel
Hi to all
I have developed an ALV report, which is showing correct display and out put.
But when I am downloading it to excel, o/p is not coming in proper way. Fields are misplaced from there actual place and not in readable condition.
Please guide me..
Regards
AnubhavHello Lakshmiraj
I am sending you the coding of my ALV report program.
Please check.
REgards
Anubhav
*& Report YRMR033_AMENDMENT_ORDER_LIST
*& DEVELOPER : ANUBHAV GUPTA
*& DATE : 21.03.2008
*& REPORT DESCRIPTION : REPORT TO DISPLAY AMENDMENTS IN PURCDHASE ORDERS
WITH OLD VALUES AND NEW VALUES.
REPORT YRMR033_AMENDMENT_ORDER_LIST LINE-SIZE 132 NO STANDARD PAGE HEADING
LINE-COUNT 065(001)
MESSAGE-ID VR.
TABLES: DD04T,
CDHDR,
CDPOS,
DD03L,
DD41V,
T685T,
VBPA,
TPART,
KONVC,
EKKO.
TABLES : NAST, LFA1,ekpo.
SELECT-OPTIONS: "XUDATE FOR nast-erdat OBLIGATORY, "Created on date
XUDATE FOR CDHDR-UDATE OBLIGATORY, "Amendment date
S_EKGRP FOR EKKO-EKGRP,
s_lifnr for ekko-lifnr.
SELECTION-SCREEN SKIP.
DATA: WFLAG,
WCHANGENR LIKE CDHDR-CHANGENR.
DATA: INDTEXT(60) TYPE C.
DATA: BEGIN OF ICDHDR OCCURS 50.
INCLUDE STRUCTURE CDHDR.
DATA: END OF ICDHDR.
DATA: BEGIN OF ICDSHW OCCURS 50.
INCLUDE STRUCTURE CDSHW.
DATA: END OF ICDSHW.
DATA: BEGIN OF EKKEY,
EBELN LIKE EKET-EBELN,
EBELP LIKE EKET-EBELP,
ETENR LIKE EKET-ETENR,
END OF EKKEY.
DATA: BEGIN OF ITAB OCCURS 50,
BEGIN OF EKKEY,
EBELN LIKE EKET-EBELN,
EBELP LIKE EKET-EBELP,
ETENR LIKE EKET-ETENR,
END OF EKKEY,
ebeln like ekko-ebeln,
ebelp like ekpo-ebelp,
CHANGENR LIKE CDHDR-CHANGENR,
UDATE LIKE CDHDR-UDATE,
UTIME LIKE CDHDR-UTIME,
USERNAME LIKE CDHDR-USERNAME,
CHNGIND LIKE CDSHW-CHNGIND,
FNAME LIKE CDSHW-FNAME, "ADDED BY ANUBHAV
FTEXT LIKE CDSHW-FTEXT,
OUTLEN LIKE CDSHW-OUTLEN,
F_OLD LIKE CDSHW-F_OLD,
F_NEW LIKE CDSHW-F_NEW,
END OF ITAB.
DATA : BEGIN OF ITAB1 OCCURS 0,
EBELN LIKE EKET-EBELN,
bedat like ekko-bedat,
EBELP LIKE EKET-EBELP,
txz01 like ekpo-txz01,
lifnr like ekko-lifnr,
name1 like lfa1-name1,
UDATE LIKE CDHDR-UDATE,
FTEXT LIKE CDSHW-FTEXT,
F_OLD LIKE CDSHW-F_OLD,
ekgrp like ekko-ekgrp,
F_NEW LIKE CDSHW-F_NEW,
CHANGENR LIKE CDHDR-CHANGENR,
UTIME LIKE CDHDR-UTIME,
USERNAME LIKE CDHDR-USERNAME,
CHNGIND LIKE CDSHW-CHNGIND,
FNAME LIKE CDSHW-FNAME, "ADDED BY ANUBHAV
OUTLEN LIKE CDSHW-OUTLEN,
AMDNO TYPE CHAR4,
END OF ITAB1.
DATA: OLD_OBJECTID LIKE CDHDR-OBJECTID.
INTERNAL TABLES
----"modification
DATA: BEGIN OF I_NAST OCCURS 0,
OBJKY TYPE NAST-OBJKY,
ERDAT TYPE NAST-ERDAT,
KAPPL TYPE NAST-KAPPL,
KSCHL TYPE NAST-KSCHL,
PARVW TYPE NAST-PARVW,
PARNR TYPE NAST-PARNR,
ERUHR TYPE NAST-ERUHR,
AMDNO TYPE CHAR4,
EBELN TYPE EKKO-EBELN,
END OF I_NAST.
DATA : I_NAST1 LIKE TABLE OF I_NAST WITH HEADER LINE.
DATA: BEGIN OF I_TAB OCCURS 0,
OBJKY TYPE NAST-OBJKY,
ERDAT TYPE NAST-ERDAT,
KAPPL TYPE NAST-KAPPL,
KSCHL TYPE NAST-KSCHL,
PARVW TYPE NAST-PARVW,
PARNR TYPE NAST-PARNR,
ERUHR TYPE NAST-ERUHR,
END OF I_TAB.
DATA: INDEX TYPE I.
TYPE-POOLS : SLIS.
ALV Declarations *
DATA: W_REPID LIKE SY-REPID,
P_I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
P_I_HEADING TYPE SLIS_T_LISTHEADER,
I_LAYOUT TYPE SLIS_LAYOUT_ALV,
I_EVENTS TYPE SLIS_T_EVENT,
I_HEADING TYPE SLIS_T_LISTHEADER.
DATA: WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
SR TYPE I.
INITIALIZATION----
INITIALIZATION.
CLEAR I_NAST.
CLEAR I_TAB.
REFRESH I_NAST.
REFRESH I_TAB.
AT SELECTIN SCREEN----
AT SELECTION-SCREEN.
PERFORM DATA_VALIDATION.
TOP OF PAGE----
TOP-OF-PAGE.
PERFORM TOP_OF_PAGE.
END OF PAGE----
END-OF-PAGE.
START OF SELECTION----
START-OF-SELECTION.
PERFORM BUILD_COMMENT USING I_HEADING.
PERFORM EVENT_BUILD CHANGING I_EVENTS.
SELECT * FROM EKKO . " WHERE EBELN IN XEBELN AND
*LIFNR IN XLIFNR.
CLEAR CDHDR.
CLEAR CDPOS.
CDHDR-OBJECTCLAS = 'EINKBELEG'.
CDHDR-OBJECTID = EKKO-EBELN.
PERFORM GETCHGDOCS.
ENDSELECT.
DELETE ITAB WHERE ( FNAME NE 'NETPR'
AND FNAME NE 'NETWR'
AND FNAME NE 'MENGE' ).
loop at itab.
read table itab.
itab-ebeln = itab-ekkey+0(10).
itab-ebelp = itab-ekkey+11(4).
modify itab.
endloop.
LOOP AT ITAB.
MOVE-CORRESPONDING ITAB TO ITAB1.
APPEND ITAB1.
ENDLOOP.
LOOP AT ITAB1.
SELECT OBJKY ERDAT KAPPL KSCHL PARVW PARNR ERUHR
FROM NAST
INTO CORRESPONDING FIELDS OF TABLE I_NAST
WHERE OBJKY = ITAB1-EBELN
AND KAPPL = 'EF'
AND KSCHL = 'ZNEU'
AND PARVW = 'LF'
AND SPRAS = SY-LANGU.
IF SY-SUBRC NE 0.
DELETE ITAB1.
ENDIF.
LOOP AT I_NAST.
MOVE-CORRESPONDING I_NAST TO I_NAST1.
APPEND I_NAST1.
ENDLOOP.
ENDLOOP.
SORT I_NAST1 BY OBJKY ASCENDING ERDAT DESCENDING ERUHR DESCENDING.
DELETE ADJACENT DUPLICATES FROM I_NAST1 COMPARING OBJKY.
* Select data from TABLE NAST to get ebeln before selected date
IF I_NAST1[] IS NOT INITIAL.
SELECT OBJKY ERDAT KAPPL KSCHL PARVW PARNR ERUHR
FROM NAST
INTO CORRESPONDING FIELDS OF TABLE I_TAB
FOR ALL ENTRIES IN I_NAST1
WHERE OBJKY = I_NAST1-OBJKY
AND ERDAT <= I_NAST1-ERDAT
AND PARNR = I_NAST1-PARNR
AND KAPPL = 'EF'
AND KSCHL = 'ZNEU'
AND PARVW = 'LF'
AND SPRAS = SY-LANGU.
ENDIF.
Logic to get no of amendments for one po
LOOP AT I_NAST1.
CLEAR INDEX.
LOOP AT I_TAB WHERE OBJKY = I_NAST1-OBJKY.
INDEX = INDEX + 1.
ENDLOOP.
I_NAST1-AMDNO = INDEX - 1.
I_NAST1-EBELN = I_NAST1-OBJKY.
MODIFY I_NAST1 TRANSPORTING AMDNO EBELN.
ENDLOOP.
*LOOP AT I_NAST1.
*READ TABLE ITAB1 WITH KEY EBELN = I_NAST1-EBELN.
*IF SY-SUBRC = 0.
*ITAB1-AMDNO = I_NAST1-AMDNO.
*MODIFY ITAB1 TRANSPORTING AMDNO .
*ENDIF.
*ENDLOOP.
DELETE I_NAST1 WHERE AMDNO = 0. "ADDED BY ANUBHAV
LOOP AT ITAB1.
READ TABLE I_NAST1 WITH KEY EBELN = ITAB1-EBELN.
IF SY-SUBRC NE 0.
DELETE ITAB1.
ENDIF.
ENDLOOP.
loop at itab1.
select single *
from ekko
into ekko
where ebeln = itab1-ebeln.
if sy-subrc = 0.
itab1-bedat = ekko-bedat.
itab1-lifnr = ekko-lifnr.
itab1-ekgrp = ekko-ekgrp.
modify itab1.
endif.
endloop.
DELETE ITAB1 WHERE EKGRP NOT IN S_EKGRP.
DELETE ITAB1 WHERE LIFNR NOT IN S_LIFNR.
loop at itab1.
select single *
from lfa1
into lfa1
where lifnr = itab1-lifnr.
if sy-subrc = 0.
itab1-name1 = lfa1-name1.
modify itab1.
endif.
endloop.
loop at itab1.
select single *
from ekpo
into ekpo
where ebeln = itab1-ebeln
and ebelp = itab1-ebelp.
if sy-subrc = 0.
itab1-txz01 = ekpo-txz01.
modify itab1.
endif.
endloop.
sort itab1 by udate descending ebeln ebelp.
building field catelogue
ADD 1 TO SR.
WA_FIELDCAT-COL_POS = SR.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-TABNAME = 'Itab1'.
WA_FIELDCAT-JUST = 'L' .
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_L = 'PO NO '.
APPEND WA_FIELDCAT TO P_I_FIELDCAT.
CLEAR WA_FIELDCAT.
ADD 1 TO SR.
WA_FIELDCAT-COL_POS = SR.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-TABNAME = 'Itab1'.
WA_FIELDCAT-JUST = 'L' .
WA_FIELDCAT-FIELDNAME = 'BEDAT'.
WA_FIELDCAT-SELTEXT_L = 'PO DATE '.
APPEND WA_FIELDCAT TO P_I_FIELDCAT.
CLEAR WA_FIELDCAT.
ADD 1 TO SR.
WA_FIELDCAT-COL_POS = SR.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-TABNAME = 'Itab1'.
WA_FIELDCAT-JUST = 'L' .
WA_FIELDCAT-FIELDNAME = 'EBELP'.
WA_FIELDCAT-SELTEXT_L = 'Item No '.
APPEND WA_FIELDCAT TO P_I_FIELDCAT.
CLEAR WA_FIELDCAT.
ADD 1 TO SR.
WA_FIELDCAT-COL_POS = SR.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-TABNAME = 'Itab1'.
WA_FIELDCAT-JUST = 'L' .
WA_FIELDCAT-FIELDNAME = 'TXZ01'.
WA_FIELDCAT-SELTEXT_L = 'Item Description'.
APPEND WA_FIELDCAT TO P_I_FIELDCAT.
CLEAR WA_FIELDCAT.
ADD 1 TO SR.
WA_FIELDCAT-COL_POS = SR.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-TABNAME = 'Itab1'.
WA_FIELDCAT-JUST = 'L' .
WA_FIELDCAT-FIELDNAME = 'LIFNR'.
WA_FIELDCAT-SELTEXT_L = 'Vendor NO '.
APPEND WA_FIELDCAT TO P_I_FIELDCAT.
CLEAR WA_FIELDCAT.
ADD 1 TO SR.
WA_FIELDCAT-COL_POS = SR.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-TABNAME = 'Itab1'.
WA_FIELDCAT-JUST = 'L' .
WA_FIELDCAT-FIELDNAME = 'NAME1'.
WA_FIELDCAT-SELTEXT_L = 'Vendor Name'.
APPEND WA_FIELDCAT TO P_I_FIELDCAT.
CLEAR WA_FIELDCAT.
ADD 1 TO SR.
WA_FIELDCAT-COL_POS = SR.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-TABNAME = 'ITAB1'.
WA_FIELDCAT-JUST = 'L' .
WA_FIELDCAT-FIELDNAME = 'UDATE'.
WA_FIELDCAT-SELTEXT_L = 'Amendment Date'.
APPEND WA_FIELDCAT TO P_I_FIELDCAT.
CLEAR WA_FIELDCAT.
ADD 1 TO SR.
WA_FIELDCAT-COL_POS = SR.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-TABNAME = 'ITAB1'.
WA_FIELDCAT-JUST = 'L' .
WA_FIELDCAT-FIELDNAME = 'FTEXT'.
WA_FIELDCAT-SELTEXT_l = 'Change Field Description'.
WA_FIELDCAT-just = 'L'.
APPEND WA_FIELDCAT TO P_I_FIELDCAT.
CLEAR WA_FIELDCAT.
ADD 1 TO SR.
WA_FIELDCAT-COL_POS = SR.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-TABNAME = 'ITAB1'.
WA_FIELDCAT-JUST = 'L' .
WA_FIELDCAT-FIELDNAME = 'F_OLD'.
WA_FIELDCAT-SELTEXT_L = 'Old Value '.
APPEND WA_FIELDCAT TO P_I_FIELDCAT.
CLEAR WA_FIELDCAT.
ADD 1 TO SR.
WA_FIELDCAT-COL_POS = SR.
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-TABNAME = 'ITAB1'.
WA_FIELDCAT-JUST = 'L' .
WA_FIELDCAT-FIELDNAME = 'F_NEW'.
WA_FIELDCAT-JUST = 'L' .
WA_FIELDCAT-SELTEXT_L = 'New Value '.
APPEND WA_FIELDCAT TO P_I_FIELDCAT.
CLEAR WA_FIELDCAT.
DATA : L_REPID TYPE SYREPID,
L_REPID1 LIKE DISVARIANT.
L_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = 'X'
I_CALLBACK_PROGRAM = L_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = I_LAYOUT
IT_FIELDCAT = P_I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'X'
IS_VARIANT = L_REPID1
IT_EVENTS = I_EVENTS
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
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = ITAB1[]
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.
*& Form GETCHGDOCS
text
FORM GETCHGDOCS.
CALL FUNCTION 'CHANGEDOCUMENT_READ_HEADERS'
EXPORTING
DATE_OF_CHANGE = CDHDR-UDATE
OBJECTCLASS = CDHDR-OBJECTCLAS
OBJECTID = CDHDR-OBJECTID
TIME_OF_CHANGE = CDHDR-UTIME
USERNAME = CDHDR-USERNAME
TABLES
I_CDHDR = ICDHDR
EXCEPTIONS
NO_POSITION_FOUND = 1
OTHERS = 2.
CHECK SY-SUBRC EQ 0.
DELETE ICDHDR WHERE CHANGE_IND EQ 'I'.
CHECK NOT ICDHDR[] IS INITIAL.
LOOP AT ICDHDR.
CHECK ICDHDR-UDATE IN XUDATE.
CHECK ICDHDR-USERNAME IN XNAME.
CALL FUNCTION 'CHANGEDOCUMENT_READ_POSITIONS'
EXPORTING
CHANGENUMBER = ICDHDR-CHANGENR
IMPORTING
HEADER = CDHDR
TABLES
EDITPOS = ICDSHW
EXCEPTIONS
NO_POSITION_FOUND = 1
OTHERS = 2.
CHECK SY-SUBRC EQ 0.
DELETE ICDSHW WHERE ( CHNGIND NE 'U' OR TABNAME NE 'EKPO' ).
LOOP AT ICDSHW.
CHECK ICDSHW-TEXT_CASE EQ SPACE.
MOVE-CORRESPONDING ICDSHW TO ITAB.
MOVE-CORRESPONDING ICDHDR TO ITAB.
MOVE ICDSHW-TABKEY+3 TO ITAB-EKKEY.
APPEND ITAB.
ENDLOOP.
ENDLOOP.
ENDFORM. "GETCHGDOCS
*& Form BUILD_COMMENT
text
-->P_I_HEADING text
FORM BUILD_COMMENT USING P_I_HEADING TYPE SLIS_T_LISTHEADER.
DATA: WA_LINE TYPE SLIS_LISTHEADER,
TEXT1(50) TYPE C,
TEXT2(40) TYPE C,
W_DATE1(10) TYPE C,
W_DATE2(10) TYPE C.
CONCATENATE ' CHAMBAL FERTILISERS AND CHEMICALS LIMITED' ' ' INTO TEXT1.
WA_LINE-TYP = 'H'.
WA_LINE-INFO = TEXT1.
APPEND WA_LINE TO P_I_HEADING.
CLEAR TEXT1.
CONCATENATE ' AMENDED ORDERS' ' ' INTO TEXT1.
WA_LINE-TYP = 'S'.
WA_LINE-INFO = TEXT1.
APPEND WA_LINE TO P_I_HEADING.
write xudate-low to w_date1 DD/MM/YYYY .
write xudate-high to w_date2 DD/MM/YYYY .
concatenate 'PERIOD FROM : ' W_DATE1 ' TO ' W_DATE2 INTO TEXT2 SEPARATED BY SPACE.
WA_LINE-TYP = 'S'.
WA_LINE-INFO = TEXT2.
APPEND WA_LINE TO P_I_HEADING.
ENDFORM. " build_comment
*& Form EVENT_BUILD
text
-->P_I_EVENTS text
FORM EVENT_BUILD CHANGING P_I_EVENTS TYPE SLIS_T_EVENT.
DATA: W_EVENT TYPE SLIS_ALV_EVENT.
CONSTANTS:
GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = P_I_EVENTS.
READ TABLE P_I_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO W_EVENT.
IF SY-SUBRC = 0.
MOVE GC_FORMNAME_TOP_OF_PAGE TO W_EVENT-FORM.
APPEND W_EVENT TO P_I_EVENTS.
ENDIF.
ENDFORM. " event_build
*& Form TOP_OF_PAGE
text
FORM TOP_OF_PAGE .
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = I_HEADING
I_LOGO = 'CFCLLOGO'.
ENDFORM. " top_of_page -
hi,
I have written an ABAP report using ALV . We need to add a button to the menu bar of the screen that appears after the report is run, not on the selection screen. And when report is executed user will choose for example STOCK then it has to go to the transaction(QA03).
thanks in advance.
Anu.Hi,
Goto SE41, create a pf-status for your alv report program.
On the next screen, click menu EXTRAS --> click option ADJUST TEMPLATES and select radiobutton LIST VIEWER --> you will get all standard buttons of alv in the pf-status.
Delete the unwanted buttons and also you can add new buttons if reqd.
Activate pf-status --> and apply in alv program.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_rep_id " report id
i_callback_pf_status_set = 'PF' " for PF-STATUS
i_callback_user_command = 'USER_COMMAND' " for User-Command
is_layout = wa_layout " for layout
it_fieldcat = it_field " field catalog
it_sort = it_sort " sort info
TABLES
t_outtab = it_final " internal table
EXCEPTIONS
program_error = 1
OTHERS = 2.
*& Form pf
* SUB-ROUTINE PF IS USED TO SET THE PF-STATUS OF THE SCREEN
* ON WHICH THE ALV GRID IS DISPLAYED
* -->RT_EXTAB
FORM pf USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZTG_STAT'.
ENDFORM. "pf
*& Form USER_COMMAND
* SUB-ROUTINE USER_COMMAND IS USED TO HANDLE THE USER ACTION
* AND EXECUTE THE APPROPIATE CODE
* -->LV_OKCODE used to capture the function code
* of the user-defined push-buttons
* -->L_SELFIELD text
FORM user_command USING lv_okcode LIKE sy-ucomm l_selfield TYPE slis_selfield.
* assign the function code to variable v_okcode
lv_okcode = sy-ucomm.
* handle the code execution based on the function code encountered
CASE lv_okcode.
* when the function code is STOCK
WHEN 'STOCK'.
SET PARAMETER ID '<param_id>' FIELD '<field_value>'.
CALL TRANSACTION 'QA03' AND SKIP FIRST SCREEN.
ENDCASE.
ENDFORM. "USER_COMMAND
Hope this helps you.
Regards,
Tarun -
How to resolve the error in bdc call transaction in ALV report
Dear Experts, i am executing the alv report program and in alv report program one bdc is there..
after executing output is showing in alv format but one button is there (update master)..when i am clicking update button the bdc is run but is not updated in the material master..after executing my bdc is not updated in mm02.
how to resove it?
CALL TRANSACTION 'MM02' USING BDCDATA MODE MODE
UPDATE 'S'
MESSAGES INTO MESSTAB.Hi Kaustav,
Looking at the code you attached, it appears to me that your BDC (Form USER_COMMAND) is not executed at all as you haven't passed the 'USER_COMMAND' in FM REUSE_ALV_GRID_DISPLAY for ALV display.
You must pass the importing parameter I_CALLBACK_USER_COMMAND of this FM as 'USER_COMMAND', only then this form will be executed and your BDC will run.
Thereafter, in case your BDC update fails, you can put a break-point in the form (at CALL TRANSACTION statement) and analyze the message table MESSTAB.
Hope it helps.
Regards,
Sapeksh
Maybe you are looking for
-
Help with printing book made with i photo
Hi, Can somebody help me. I am trying to buy an album i created with iphoto under the project tab and it won't work. It keep saying that the connection cannot be made?
-
Where does openbox get its icon information from? I'm using URxvt, but I get the ugly default box as an icon. I have an icon I downloaded that I put in /usr/share/pixmaps. It's set up correctly in my pypanel, but openbox doesn't display the icon.
-
Hello - I purchased a QT Pro version 7 key back in April. Registered fine. Then my iMac went back to Apple to be repaired - as Apple could not repair it (replacement screens unavailable) I was sent a replacement machine. Now attempting to 'register'
-
Problems installing photoshop cs3
I have downloaded the trial version of photoshop cs3 from the adobe website. after starting the setup and the system check i get the error that it cannot carry on with the installation because it conflicts with CS3! i have noted that there are 2 cs3
-
Connecting an iphone to a new mediathek
Hello, I have an iphone which was synchronized with a macbook pro. Now I got a new macbook pro because the old one was damaged. When I try to synchronize my iphone with the new macbook I get the message: "This iphone is connected to another mediathek