RFQs - Conditions to be fetched in ALV Report
Hi,
I need to fetch Conditions Types and corresponding Condition Amounts for list of RFQs in ALV based report.
Problem at my end is :
For a RFQ ,corresponding Document Condition No. at EKKO table for Document Type 'AN' is absent
(i.e Document Conditon No is not maintained in system for any of RFQs .)
Please suggest a way to fetch conditions for RFQs (in general).
Regards,
Abhishek Sawant
Edited by: aBHISHEK sAWANT on Nov 10, 2009 12:32 PM
Hi Abhishek,
How it's Solved?
i need to pick the same condition values from RFQ in my report.
please help.
Regards,
Satish reddy.
Similar Messages
-
How can i call a condition type into my ALV report
I am developing one ALV report in that how can i call a condition type.I am one condition type PB00 for special price.This special price column should be present at the output list.This special price is not there any one of the database tables.So we will create one condition type for this.How can I develop one condition type and how we may call this condition type into my ALV report.
V/06 is the condition type transaction .You attach a Access sequence to that which is stored in V/07 .
there you can also get based on key combination tables names .
which you can used in your report to include in the ALV .
Contion type PB00 Access sequence PB00
which will have step say
Step Table combination
1 071 Material plant
2 142 SO/dc/DV
here Application would A and table would A table number .
for eg .A071 . -
How can I call a condition type in my ALV report
I am having one condition type.Then how can I call a condition type in my ALV report.
Hi,
If you have any conditions then filter your data according to that conditions through SQl queries.
And then display it through ALV.
Regards
Mudit -
Creating a simple ALV report based on join condition
Dear All
SAP Version: ECC6 EHP7
I wan to create simple ALV report based on join condition. can anyone provide me the complete steps to create this report.
Regards,Hi Syed,
Please check the link,
ALV report - Joining 2 tables
Regards,
Prakash. -
Hi,
I have a issue in ALV Report for displaying one field's data into output.
I am getting data into all other fields in ALV Report except for this field.
This field & related fields are declared as below: in final internal table.
sta_no TYPE z3status,
status(10) TYPE c,
Here z3status is of type Char(1).
In Report
I have put a condition :
IF i_tab-sta_no EQ 1.
i_tab-status = 'Created'.
ELSE.
i_tab-status = 'Closed'.
ENDIF.
and to field catalog also i am passing right information as for every other field in ALV Report.
Till the point use of REUSE_ALV_LIST_DISPLAY F.M also final internal table is having status field filled.
But in output nothing gets displayed for Status field.
Can anybody tell me what can be the issue!
Thanks in advance.
Thanks,
Deep.Hi,
I have no problem in data fetching into final internal table.
Everything is coming well to REUSE_ALV_DISPLAY F.M.
But still Status field data is not getting displayed.
I have posted some code for reference:
LOOP AT t_z3manboxid INTO wa_z3manboxid.
wa_result-manifest_no = wa_z3manboxid-zmanno.
wa_result-item_no = wa_z3manboxid-item_no.
IF l_item_no NE wa_z3manboxid-item_no.
wa_result-piece_quantity = wa_z3manboxid-vemng.
wa_result-unit = wa_z3manboxid-vemeh.
wa_result-manifester = wa_z3manboxid-usnam.
wa_result-manifest_sta_no = wa_z3manboxid-z3status.
IF wa_result-manifest_sta_no EQ 1.
wa_result-manifest_status = c_created.
ELSEIF wa_result-manifest_sta_no EQ 2.
wa_result-manifest_status = c_in_transit.
ELSEIF wa_result-manifest_sta_no EQ 3.
wa_result-manifest_status = c_arrived.
ELSEIF wa_result-manifest_sta_no EQ 4.
wa_result-manifest_status = c_closed.
ENDIF.
ENDIF.
l_item_no = wa_z3manboxid-item_no.
APPEND wa_result TO t_result.
CLEAR: wa_result, wa_z3manboxid.
ENDLOOP.
Building field catalog following code is added:
For status call is as below:
PERFORM f_build_fieldcat USING c_tab
c_manifest_status
c_space
c_space
c_mannf_status
c_space1
15.
FORM f_build_fieldcat USING p_tabname p_fldname
p_rtabname p_rfldname
p_fldhdg p_check
p_length.
CLEAR t_fieldcat_ln1.
ADD 1 TO g_col_pos.
t_fieldcat_ln1-tabname = p_tabname.
t_fieldcat_ln1-fieldname = p_fldname.
t_fieldcat_ln1-ref_tabname = p_rtabname.
t_fieldcat_ln1-ref_fieldname = p_rfldname.
t_fieldcat_ln1-ddictxt = c_l.
t_fieldcat_ln1-seltext_l = p_fldhdg.
t_fieldcat_ln1-no_zero = space.
t_fieldcat_ln1-do_sum = space.
t_fieldcat_ln1-col_pos = g_col_pos.
t_fieldcat_ln1-no_out = space.
t_fieldcat_ln1-just = c_c.
t_fieldcat_ln1-qfieldname = space.
t_fieldcat_ln1-checkbox = p_check.
t_fieldcat_ln1-input = p_check.
t_fieldcat_ln1-reptext_ddic = p_fldhdg.
IF p_fldname EQ c_manno.
t_fieldcat_ln1-key = c_x.
t_fieldcat_ln1-hotspot = c_x.
ELSE.
t_fieldcat_ln1-key = space.
t_fieldcat_ln1-hotspot = p_check.
ENDIF.
t_fieldcat_ln1-outputlen = p_length.
t_fieldcat_ln1-intlen = p_length.
t_fieldcat_ln1-ddic_outputlen = p_length.
APPEND t_fieldcat_ln1 TO t_fieldcat1.
ENDFORM. " f_build_fieldcat
FORM f_build_sortcat USING p_fldname.
CLEAR t_sortcat_ln1.
ADD 1 TO g_col_pos.
t_sortcat_ln1-spos = g_col_pos.
t_sortcat_ln1-fieldname = p_fldname.
t_sortcat_ln1-up = c_x.
t_sortcat_ln1-down = space.
t_sortcat_ln1-subtot = c_x.
APPEND t_sortcat_ln1 TO t_sortcat1.
ENDFORM. " f_build_sortcat
FORM f_build_layout.
t_layout1-zebra = c_x.
t_layout1-no_vline = c_space1.
t_layout1-reprep = c_x.
t_layout1-detail_popup = c_x.
t_layout1-window_titlebar = text-005.
t_layout1-no_scrolling = c_space1.
t_layout1-detail_titlebar = text-005.
t_layout1-numc_sum = c_x.
t_layout1-get_selinfos = c_x.
t_layout1-min_linesize = 132.
ENDFORM. " f_build_layout
DATA: l_pgm TYPE syrepid,
l_exit(1) TYPE c.
CLEAR: l_pgm,
l_exit.
l_pgm = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = l_pgm
i_callback_user_command = c_user_command
is_layout = t_layout1
it_fieldcat = t_fieldcat1
i_save = c_a
it_events = t_eventcat1
IMPORTING
e_exit_caused_by_caller = l_exit
TABLES
t_outtab = t_result
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc NE 0.
l_exit = l_exit.
ENDIF.
To ALV F.M t_result table is updated with correct data.
But it is not getting displayed.
What can be the reason!
Can anybody give the solution!
Thanks for your replies.
Thanks,
Deep. -
Hello everyone,
I have an ALV report with a radiobutton in the selection screen. This radiobutton has 4 options(for example): Office A, Office B, Office C, Office D.
When i choose Office C, the ALV will report data concerning only to this Office (all fields in the table are common to all Offices).
But besides this, i would like to check at the beginning if the user trying to access the ALV report is from Office A,B, C or D. If he is from Office B, he should only have access to ALV with radiobutton chosen to Office B.
Can anyone help me with a suggestion ?
I read something about authorization groups. Is this an option here ?Here is a sample code with similar functionality... Using this to develop your logic....
Type pools Declaration..............................................*
TYPE-POOLS SLIS. " Global types
Range tables........................................................*
RANGES R_LIFEX FOR LIKP-LIFEX. " External Identification of
" Delivery note
selection screen elememts...........................................*
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-009.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS:
P_OPEN RADIOBUTTON GROUP R1 DEFAULT 'X'.
" Open orders
SELECTION-SCREEN COMMENT (20) TEXT-001 FOR FIELD P_OPEN.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS:
P_PREPAY RADIOBUTTON GROUP R1. " Prepay orders
SELECTION-SCREEN COMMENT (20) TEXT-002 FOR FIELD P_PREPAY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B1.
Constants variables.................................................*
CONSTANTS:
C_L TYPE C VALUE 'L', " SD document object
C_J TYPE C VALUE 'J', " SD document category
C_A TYPE C VALUE 'A', " Status of Not yet processed
C_B TYPE C VALUE 'B', " Status of Partially processed
C_LF(2) TYPE C VALUE 'LF', " Delivery Type
C_E TYPE C VALUE 'E', " Language
C_TON(3) TYPE C VALUE 'TON', " Material unit
C_TO(2) TYPE C VALUE 'TO', " Material unit
C_X TYPE C VALUE 'X', " Parameter value
C_I TYPE C VALUE 'I', " Sign
C_CP(2) TYPE C VALUE 'CP', " Option
C_PP1(3) TYPE C VALUE 'PP*', " Prepay order
C_PP2(3) TYPE C VALUE 'pP*', " Prepay order
C_PP3(3) TYPE C VALUE 'pp*', " Prepay order
C_PP4(3) TYPE C VALUE 'Pp*', " Prepay order
C_0 TYPE C VALUE '0', " Zero
C_UREA(40) TYPE C VALUE 'UREA(GRANULAR)',
" Material name
C_30%(3) TYPE C VALUE '30%', " Material name
C_32%(3) TYPE C VALUE '32%', " Material name
C_28%(3) TYPE C VALUE '28%', " Material name
C_NH3(3) TYPE C VALUE 'NH3', " Material name
C_AN(3) TYPE C VALUE 'AN', " Material name
C_UAN(3) TYPE C VALUE 'UAN', " Material name
C_30(2) TYPE C VALUE '30', " Output length
C_20(2) TYPE C VALUE '20', " Output length
C_1_102311 TYPE P DECIMALS 6 VALUE '1.102311',
" Conversion factor
Begin of Deletion CS1K931253
C_METHANOL(40) TYPE C VALUE 'METHANOL',
" Material name
End of Deletion CS1K931253
C_TOP_OF_PAGE(15) TYPE C VALUE 'TOP_OF_PAGE',
" Top of page event
C_BEFORE_LINE_OUTPUT(25) TYPE C VALUE 'BEFORE_LINE_OUTPUT',
" Before line output event
C_END_OF_LIST(15) TYPE C VALUE 'END_OF_LIST',
" End of list
Begin of Insertion CS1K931253
C_OPEN(4) TYPE C VALUE 'OPEN',
" Open orders
C_PREPAY(6) TYPE C VALUE 'PREPAY'.
" Prepay orders
End of Insertion CS1K931253
Working Variable declarations *
DATA:
W_NUMBER TYPE I, " Plant number
W_INDEX TYPE SY-TABIX VALUE '1', " Table Index
W_MATNR TYPE LIPS-MATNR, " Material Number
Begin of Deletion - CS1K931253
W_LFIMG TYPE LIPS-LFIMG, " Actual quantity delivered
W_TOTAL32 TYPE LIPS-LFIMG, " Actual quantity delivered
End of Deletion - CS1K931253
W_LFIMG TYPE P DECIMALS 3, " Actual quantity delivered
W_TOTAL32 TYPE P DECIMALS 3, " Actual quantity delivered
W_INCR TYPE I VALUE 5, " Increment variable
W_PRDCT(40) TYPE C, " Product Name
Field string Declarations *
*Field string to hold open delivery quantities
BEGIN OF FS_OPEN_DEL,
VTEXT TYPE TVSTT-VTEXT, " Plant name
MAT_NUM TYPE I, " Plant Number
PRDCT(40) TYPE C, " Product Name
QTYA TYPE LIPS-LFIMG, " Quantity moved by Truck
QTYB TYPE LIPS-LFIMG, " Quantity moved by Rail
QTYC TYPE LIPS-LFIMG, " Quantity moved by Barge
QTYD TYPE LIPS-LFIMG, " Quantity moved by Pipe
QTYE TYPE LIPS-LFIMG, " Quantity moved by Vessel
QTYT TYPE LIPS-LFIMG, " Total Quantity moved
QTYG TYPE LIPS-LFIMG, " Quantity moved by
VRKME TYPE LIPS-VRKME, " Sales unit
END OF FS_OPEN_DEL,
*Field string to hold open deliveries
BEGIN OF FS_LIKPUK,
VBELN TYPE LIKP-VBELN, " Delivery
END OF FS_LIKPUK,
*Field string to hold Ship point description
BEGIN OF FS_TVSTT,
VSTEL TYPE LIKP-VSTEL, " Plant
VTEXT TYPE TVSTT-VTEXT, " Plant Name
END OF FS_TVSTT,
*Field string to hold delivery item documents data
BEGIN OF FS_LIPS,
VBELN TYPE LIKP-VBELN, " Delivery
POSNR TYPE LIPS-POSNR, " Item
MATNR TYPE LIPS-MATNR, " Material Number
LFIMG TYPE LIPS-LFIMG, " Quantity delivered
VRKME TYPE LIPS-VRKME, " Sales unit
END OF FS_LIPS,
*Field string to hold delivery header documents data
BEGIN OF FS_LIKP,
VBELN TYPE LIKP-VBELN, " Delivery
VSTEL TYPE LIKP-VSTEL, " Plant
VSBED TYPE LIKP-VSBED, " Shipping Condition
END OF FS_LIKP,
Field string to hold Plants and its delivered quantities
BEGIN OF FS_DEL_QUAN,
PRODNAME(40), " Product Name
VTEXT TYPE TVSTT-VTEXT, " Plant
VSBED TYPE LIKP-VSBED, " Shipping Condition
LFIMG TYPE LIPS-LFIMG, " Delivered quantity
VRKME TYPE LIPS-VRKME, " Sales unit
END OF FS_DEL_QUAN,
Field String to hold material text
BEGIN OF FS_MAKT,
MATNR TYPE MAKT-MATNR, " Material Number
MAKTX TYPE MAKT-MAKTX, " Material text
END OF FS_MAKT,
FS_FIELDCAT TYPE LINE OF SLIS_T_FIELDCAT_ALV,
FS_EVENTS TYPE LINE OF SLIS_T_EVENT.
Internal Table Declarations *
DATA:
Table to hold open delivery quantities
T_OPEN_DEL LIKE STANDARD TABLE
OF FS_OPEN_DEL,
Table to hold open deliveries
T_LIKPUK LIKE STANDARD TABLE
OF FS_LIKPUK,
Table to hold Ship point description
T_TVSTT LIKE STANDARD TABLE
OF FS_TVSTT,
Table to hold delivery item documents data
T_LIPS LIKE STANDARD TABLE
OF FS_LIPS,
Table to hold delivery item documents data
T_LIPS2 LIKE STANDARD TABLE
OF FS_LIPS,
Table to hold delivery header documents data
T_LIKP LIKE STANDARD TABLE
OF FS_LIKP,
Table to hold delivery header documents data
T_LIKP2 LIKE STANDARD TABLE
OF FS_LIKP,
Table to hold Plants and its delivered quantities
T_DEL_QUAN LIKE STANDARD TABLE
OF FS_DEL_QUAN,
Table to hold Material text
T_MAKTX LIKE STANDARD TABLE
OF FS_MAKT,
Field catalog...
T_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
Events...
T_EVENTS TYPE SLIS_T_EVENT.
START-OF-SELECTION *
START-OF-SELECTION.
Retrives Open deliveries
PERFORM GET_DELS.
Retrives Open delivery data
PERFORM GET_ORDER_DATA.
Retrives Delivery item data
PERFORM GET_ITEM_DATA.
Gets Plant description
PERFORM GET_SHIPPOINT_TEXT.
Fetch Material description.
PERFORM GET_MATTEXT.
Connects Plant and products delivered by it
PERFORM CONNECT_PLANT_PRODUCT_DATA.
Sums up quantities based on Shipping condition
PERFORM COLLECT_DATA_BY_SHIPTYPE.
Changing UAN 28% to UAN 32%
PERFORM CHANGE_UAN.
END-OF-SELECTION *
END-OF-SELECTION.
Displays the data
PERFORM DISPLAY_DATA.
Form GET_DELS
This subroutine gets all open deliveries
No Parameter interface
FORM GET_DELS.
*Get all open deliveries
SELECT VBELN " Delivery
APPENDING TABLE T_LIKPUK
FROM VBUK
PACKAGE SIZE 5000
WHERE ( WBSTK = C_A OR WBSTK = C_B )
AND VBTYP = C_J
AND VBOBJ = C_L.
ENDSELECT.
IF SY-SUBRC NE 0.
MESSAGE I280(LF).
STOP.
ENDIF. " IF SY-SUBRC NE 0.
ENDFORM. " GET_DELS
Form GET_ORDER_DATA
This subroutine gets delivery header data
No Parameter interface
FORM GET_ORDER_DATA .
IF P_PREPAY EQ C_X.
Fill the Pattern required as pp, any case.
REFRESH R_LIFEX.
R_LIFEX-SIGN = C_I.
R_LIFEX-OPTION = C_CP.
R_LIFEX-LOW = C_PP1.
APPEND R_LIFEX.
R_LIFEX-LOW = C_PP2.
APPEND R_LIFEX.
R_LIFEX-LOW = C_PP3.
APPEND R_LIFEX.
R_LIFEX-LOW = C_PP4.
APPEND R_LIFEX.
Get delivery information.
IF T_LIKPUK IS NOT INITIAL.
SELECT VBELN " Delivery
VSTEL " Plant
VSBED " Shipping condition
FROM LIKP
INTO TABLE T_LIKP
FOR ALL ENTRIES IN T_LIKPUK
WHERE VBELN = T_LIKPUK-VBELN
AND LFART = C_LF
AND LIFEX IN R_LIFEX
AND LIFSK EQ SPACE.
IF SY-SUBRC NE 0.
MESSAGE I280(LF).
STOP.
ENDIF. " IF SY-SUBRC NE 0.
ENDIF. " IF T_LIKPUK IS NOT INITIAL
ELSE.
IF T_LIKPUK IS NOT INITIAL.
SELECT VBELN " Delivery
VSTEL " Plant
VSBED " Shipping condition
FROM LIKP
INTO TABLE T_LIKP
FOR ALL ENTRIES IN T_LIKPUK
WHERE VBELN = T_LIKPUK-VBELN
AND LFART = C_LF
AND LIFSK EQ SPACE.
IF SY-SUBRC NE 0.
MESSAGE I280(LF).
STOP.
ENDIF. " IF SY-SUBRC NE 0.
ENDIF. " IF T_LIKPUK IS NOT INITIAL
ENDIF. " IF P_PREPAY EQ C_X.
T_LIKP2 = T_LIKP.
REFRESH T_LIKPUK.
ENDFORM. " GET_ORDER_DATA
Form GET_ITEM_DATA
This subroutine gets delivery item data
No Parameter interface
FORM GET_ITEM_DATA .
Get delivery item information.
IF T_LIKP IS NOT INITIAL.
SELECT VBELN " Delivery
POSNR " Item
MATNR " Material Number
LFIMG " Delivered Quantity
VRKME " Sales Unit
FROM LIPS
INTO TABLE T_LIPS
FOR ALL ENTRIES IN T_LIKP
WHERE VBELN = T_LIKP-VBELN
AND LFIMG NE 0.
IF SY-SUBRC NE 0.
STOP.
ENDIF. " IF SY-SUBRC NE 0.
ENDIF. " IF T_LIKP IS NOT INITIAL.
Begin of Insertion CS1K931253
SORT T_LIPS BY VBELN POSNR.
DELETE ADJACENT DUPLICATES FROM T_LIPS COMPARING VBELN.
End of Insertion CS1K931253
T_LIPS2 = T_LIPS.
ENDFORM. " GET_ITEM_DATA
Form GET_SHIPPOINT_TEXT
This subroutine gets Shipping point text
No Parameter interface
FORM GET_SHIPPOINT_TEXT .
Retrieve Shipping point texts, for unique shipping points.
SORT T_LIKP2 BY VSTEL.
DELETE ADJACENT DUPLICATES FROM T_LIKP2 COMPARING VSTEL.
IF T_LIKP2 IS NOT INITIAL.
SELECT VSTEL " Plant
VTEXT " Plant description
FROM TVSTT
INTO TABLE T_TVSTT
FOR ALL ENTRIES IN T_LIKP2
WHERE SPRAS = C_E
AND VSTEL = T_LIKP2-VSTEL.
IF SY-SUBRC NE 0.
Sy-subrc check not required
ENDIF. " IF SY-SUBRC NE 0
ENDIF. " IF T_LIKP2 IS NOT INITIAL.
ENDFORM. " GET_SHIPPOINT_TEXT
*& Form GET_MATTEXT
This subroutine fetches Material description
No Parameter interface
FORM GET_MATTEXT .
SORT T_LIPS2 BY MATNR.
DELETE ADJACENT DUPLICATES FROM T_LIPS2 COMPARING MATNR.
Fetch Matrial text
IF T_LIPS2 IS NOT INITIAL.
SELECT MATNR " Material Number
MAKTX " Material text
INTO TABLE T_MAKTX
FROM MAKT
FOR ALL ENTRIES IN T_LIPS2
WHERE MATNR EQ T_LIPS2-MATNR
Begin of insertion CS1K931253
AND MATNR NE '000000000000030014'
End of insertion CS1K931253
AND SPRAS = SY-LANGU.
IF SY-SUBRC NE 0.
Sy-subrc check not required
ENDIF. " IF SY-SUBRC NE 0
ENDIF. " IF T_LIPS2 IS NOT INITIAL.
ENDFORM. " GET_MATTEXT
Form CONNECT_PLANT_PRODUCT_DATA
This subroutine Connects Plant and quantity delivered by it
No Parameter interface
FORM CONNECT_PLANT_PRODUCT_DATA.
SORT T_LIKP BY VBELN.
SORT T_TVSTT BY VSTEL.
SORT T_MAKTX BY MATNR.
LOOP AT T_LIPS INTO FS_LIPS.
Getting Plant Name
READ TABLE T_LIKP INTO FS_LIKP WITH KEY VBELN = FS_LIPS-VBELN
BINARY SEARCH.
IF SY-SUBRC EQ 0.
READ TABLE T_TVSTT INTO FS_TVSTT WITH KEY VSTEL = FS_LIKP-VSTEL
BINARY SEARCH.
IF SY-SUBRC EQ 0.
FS_DEL_QUAN-VTEXT = FS_TVSTT-VTEXT.
ENDIF. " IF SY-SUBRC EQ 0
ENDIF. " IF SY-SUBRC EQ 0
Getting Ship Type.
FS_DEL_QUAN-VSBED = FS_LIKP-VSBED.
Getting Quantity.
IF FS_LIPS-VRKME EQ C_TO.
Begin of Deletion - CS1K931174
PERFORM CONVERT_UNIT.
End of Deletion - CS1K931174
Begin of Insertion - CS1K931174
FS_DEL_QUAN-VRKME = C_TON.
FS_DEL_QUAN-LFIMG = FS_LIPS-LFIMG * C_1_102311.
End of Insertion - CS1K931174
ELSE.
FS_DEL_QUAN-LFIMG = FS_LIPS-LFIMG.
FS_DEL_QUAN-VRKME = FS_LIPS-VRKME.
ENDIF. " IF FS_LIPS-VRKME EQ C_TO
Getting Product Name
W_MATNR = FS_LIPS-MATNR.
SHIFT W_MATNR LEFT DELETING LEADING C_0.
CASE W_MATNR.
Begin of Deletion - CS1K931174
WHEN '10023'.
FS_DEL_QUAN-PRODNAME = C_METHANOL.
End of Deletion - CS1K931174
WHEN '10024'.
FS_DEL_QUAN-PRODNAME = C_UREA.
WHEN '10026'.
FS_DEL_QUAN-PRODNAME = C_30%.
WHEN '10027'.
FS_DEL_QUAN-PRODNAME = C_32%.
WHEN '10030'.
FS_DEL_QUAN-PRODNAME = C_NH3.
WHEN '10031'.
FS_DEL_QUAN-PRODNAME = C_28%.
WHEN '36052'.
FS_DEL_QUAN-PRODNAME = C_AN.
WHEN OTHERS.
READ TABLE T_MAKTX INTO FS_MAKT WITH KEY MATNR = FS_LIPS-MATNR
BINARY SEARCH.
IF SY-SUBRC EQ 0.
FS_DEL_QUAN-PRODNAME = W_MATNR.
ENDIF. " IF SY-SUBRC NE 0
ENDCASE. " CASE FS_MATNR
Begin of Insertion - CS1K931174
IF W_MATNR NE '10023'.
End of Insertion - CS1K931174
APPEND FS_DEL_QUAN TO T_DEL_QUAN.
Begin of Insertion - CS1K931174
ENDIF. " IF W_MATNR NE '10023'.
End of Insertion - CS1K931174
CLEAR:
FS_DEL_QUAN,
FS_LIKP,
FS_LIPS,
FS_TVSTT,
FS_MAKT.
ENDLOOP. " LOOP AT T_LIPS INTO FS_LIPS
REFRESH:
T_LIKP,
T_LIPS.
CLEAR:
FS_LIKP,
FS_LIPS.
ENDFORM. " CONNECT_PLANT_PRODUCT_DATA
Form COLLECT_DATA_BY_SHIPTYPE
This subroutine adds quantity based on shipping condition
No Parameter interface
FORM COLLECT_DATA_BY_SHIPTYPE .
SORT T_DEL_QUAN BY PRODNAME VTEXT VSBED.
LOOP AT T_DEL_QUAN INTO FS_DEL_QUAN.
Adding delivered quantites based on Shiiping condition
CASE FS_DEL_QUAN-VSBED.
WHEN '01'.
FS_OPEN_DEL-QTYA = FS_OPEN_DEL-QTYA + FS_DEL_QUAN-LFIMG.
WHEN '02'.
FS_OPEN_DEL-QTYB = FS_OPEN_DEL-QTYB + FS_DEL_QUAN-LFIMG.
WHEN '03'.
FS_OPEN_DEL-QTYC = FS_OPEN_DEL-QTYC + FS_DEL_QUAN-LFIMG.
WHEN '04'.
FS_OPEN_DEL-QTYD = FS_OPEN_DEL-QTYD + FS_DEL_QUAN-LFIMG.
WHEN '05'.
FS_OPEN_DEL-QTYE = FS_OPEN_DEL-QTYE + FS_DEL_QUAN-LFIMG.
ENDCASE. " CASE FS_DEL_QUAN-VSBED
FS_OPEN_DEL-VRKME = FS_DEL_QUAN-VRKME.
AT END OF VTEXT.
FS_OPEN_DEL-VTEXT = FS_DEL_QUAN-VTEXT.
FS_OPEN_DEL-PRDCT = FS_DEL_QUAN-PRODNAME.
FS_OPEN_DEL-QTYT = FS_OPEN_DEL-QTYA + FS_OPEN_DEL-QTYB +
FS_OPEN_DEL-QTYC + FS_OPEN_DEL-QTYD +
FS_OPEN_DEL-QTYE.
CASE FS_OPEN_DEL-PRDCT.
Begin of Deletion - CS1K931174
WHEN C_METHANOL.
FS_OPEN_DEL-MAT_NUM = 1.
End of Deletion - CS1K931174
WHEN C_UREA.
FS_OPEN_DEL-MAT_NUM = 2.
WHEN C_30%.
FS_OPEN_DEL-MAT_NUM = 3.
WHEN C_32%.
FS_OPEN_DEL-MAT_NUM = 3.
WHEN C_28%.
FS_OPEN_DEL-MAT_NUM = 3.
WHEN C_NH3.
FS_OPEN_DEL-MAT_NUM = 4.
WHEN C_AN.
FS_OPEN_DEL-MAT_NUM = 5.
WHEN OTHERS.
IF FS_OPEN_DEL-PRDCT NE W_PRDCT.
W_INCR = W_INCR + 1.
ENDIF. " IF FS_OPEN_DEL-PRDCT...
W_PRDCT = FS_OPEN_DEL-PRDCT.
FS_OPEN_DEL-MAT_NUM = W_INCR.
ENDCASE. " CASE FS_OPEN_DEL-PRDCT
APPEND FS_OPEN_DEL TO T_OPEN_DEL.
CLEAR FS_OPEN_DEL.
ENDAT. " AT END OF VTEXT.
ENDLOOP. " LOOP AT T_DEL_QUAN INTO ...
REFRESH T_DEL_QUAN.
ENDFORM. " COLLECT_DATA_BY_SHIPTYPE
Form CHANGE_UAN
This subroutine to convert 28%UAN to 32%UAN
No Parameter interface
FORM CHANGE_UAN .
DATA LFS_OPEN_DEL2 LIKE FS_OPEN_DEL.
SORT T_OPEN_DEL BY VTEXT PRDCT.
Converting 28% UAN to 32% UAN
LOOP AT T_OPEN_DEL INTO FS_OPEN_DEL.
IF FS_OPEN_DEL-MAT_NUM = 3.
CASE FS_OPEN_DEL-PRDCT.
WHEN C_32%.
READ TABLE T_OPEN_DEL INTO LFS_OPEN_DEL2 WITH KEY
VTEXT = FS_OPEN_DEL-VTEXT
PRDCT = C_28% BINARY SEARCH.
IF SY-SUBRC EQ 0.
FS_OPEN_DEL-QTYG = FS_OPEN_DEL-QTYT + ( LFS_OPEN_DEL2-QTYT
( 875 / 1000 ) ).
ELSE.
FS_OPEN_DEL-QTYG = FS_OPEN_DEL-QTYT.
ENDIF. " IF SY-SUBRC EQ 0 .
W_TOTAL32 = W_TOTAL32 + FS_OPEN_DEL-QTYG.
MODIFY TABLE T_OPEN_DEL FROM FS_OPEN_DEL TRANSPORTING QTYG.
WHEN C_28%.
READ TABLE T_OPEN_DEL INTO LFS_OPEN_DEL2 WITH KEY
VTEXT = FS_OPEN_DEL-VTEXT
PRDCT = C_32% BINARY SEARCH.
IF SY-SUBRC NE 0.
FS_OPEN_DEL-QTYG = ( FS_OPEN_DEL-QTYT * ( 875 / 1000 ) ).
W_TOTAL32 = W_TOTAL32 + FS_OPEN_DEL-QTYG.
MODIFY TABLE T_OPEN_DEL FROM FS_OPEN_DEL TRANSPORTING QTYG.
ENDIF. " IF SY-SUBRC NE 0.
WHEN C_30%.
FS_OPEN_DEL-QTYG = ( FS_OPEN_DEL-QTYT * ( 9375 / 10000 ) ).
W_TOTAL32 = W_TOTAL32 + FS_OPEN_DEL-QTYG.
MODIFY TABLE T_OPEN_DEL FROM FS_OPEN_DEL TRANSPORTING QTYG.
ENDCASE. " CASE FS_OPEN_DEL-PRDCT
ENDIF. " IF FS_OPEN_DEL-MAT_NUM = 3
ENDLOOP. " LOOP AT T_OPEN_DEL INTO WA...
ENDFORM. " CHANGE_UAN
Form DISPLAY_DATA
This subroutine displays data
No Parameter interface
FORM DISPLAY_DATA.
IF T_OPEN_DEL IS NOT INITIAL.
Adding events to table T_EVENTS
PERFORM ADD_EVENTS.
Generating Fieldcatlog
PERFORM ADD_FIELDCATLOG.
SORT T_OPEN_DEL BY MAT_NUM VTEXT PRDCT.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME =
IS_LAYOUT =
IT_FIELDCAT = T_FIELDCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = T_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
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = T_OPEN_DEL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. " IF SY-SUBRC NE 0.
ENDIF. " IF T_OPEN_DEL IS NOT INITIAL.
ENDFORM. " DISPLAY_DATA
FORM TOP_OF_PAGE.
This subroutine displays product name in top of page
No Parameter interface
FORM TOP_OF_PAGE.
CLEAR FS_OPEN_DEL.
READ TABLE T_OPEN_DEL INDEX W_INDEX INTO FS_OPEN_DEL.
IF SY-SUBRC EQ 0.
Display Product name in Top of page.
IF FS_OPEN_DEL-PRDCT EQ C_28% OR
FS_OPEN_DEL-PRDCT EQ C_32%.
FS_OPEN_DEL-PRDCT = C_UAN.
ENDIF. " IF FS_OPEN_DEL-PRDCT EQ C_28..
ENDIF. " IF SY-SUBRC EQ 0
Begin of Deletion - CS1K931253
WRITE:
40 'OPEN'(003),
FS_OPEN_DEL-PRDCT.
Begin of Deletion - CS1K931253
Begin of Insertion - CS1K931253
IF P_OPEN EQ 'X'.
WRITE:
40 C_OPEN,
FS_OPEN_DEL-PRDCT.
ELSE.
WRITE:
40 C_PREPAY,
FS_OPEN_DEL-PRDCT.
ENDIF. " IF P_OPEN EQ 'X'
Begin of Insertion - CS1K931253
ENDFORM. " TOP_OF_PAGE
FORM BEFORE_LINE_OUTPUT
This subroutine displays total quantity for each product
No Parameter interface
FORM BEFORE_LINE_OUTPUT USING RS_LINEINFO TYPE SLIS_LINEINFO.
CLEAR FS_OPEN_DEL.
READ TABLE T_OPEN_DEL INDEX RS_LINEINFO-TABINDEX INTO FS_OPEN_DEL.
Calculating Total quantity delivered based for each product
IF FS_OPEN_DEL-MAT_NUM NE W_NUMBER AND
RS_LINEINFO-TABINDEX NE 1.
W_INDEX = RS_LINEINFO-TABINDEX.
ULINE.
Begin of Deletion - CS1K931253
WRITE:'Total quantity delivered:'(004),
W_LFIMG UNIT FS_OPEN_DEL-VRKME .
End of Deletion - CS1K931253
Begin of Insertion - CS1K931253
WRITE:'Total quantity delivered:'(004),
W_LFIMG.
End of Insertion - CS1K931253
IF W_NUMBER EQ '3'.
Begin of Deletion - CS1K931253
WRITE:/ 'Total 32%:'(005),
W_TOTAL32 UNIT FS_OPEN_DEL-VRKME .
End of Deletion - CS1K931253
Begin of Insertion - CS1K931253
WRITE:/ 'Total 32%:'(005),
W_TOTAL32.
End of Insertion - CS1K931253
ENDIF. " IF FS_NUMBER EQ '3'.
NEW-PAGE.
CLEAR W_LFIMG.
ENDIF. " FS_OPEN_DEL-MAT_NUM NE...
W_NUMBER = FS_OPEN_DEL-MAT_NUM.
W_LFIMG = W_LFIMG + FS_OPEN_DEL-QTYT.
ENDFORM. " BEFORE_LINE_OUTPUT
FORM END_OF_LIST.
This subroutine to display End of List
No Parameter interface
FORM END_OF_LIST.
FORMAT COLOR 2.
Begin of Deletion - CS1K931253
WRITE: /'Total quantity delivered:'(004),
W_LFIMG UNIT FS_OPEN_DEL-VRKME .
End of Deletion - CS1K931253
Begin of Insertion - CS1K931253
WRITE: /'Total quantity delivered:'(004),
W_LFIMG.
End of Insertion - CS1K931253
FORMAT COLOR OFF.
ENDFORM. " END_OF_LIST
Form ADD_EVENTS
This subroutine to append events to ALV
No Parameter interface
FORM ADD_EVENTS.
CLEAR FS_EVENTS.
FS_EVENTS-NAME = C_TOP_OF_PAGE.
FS_EVENTS-FORM = C_TOP_OF_PAGE.
APPEND FS_EVENTS TO T_EVENTS.
CLEAR FS_EVENTS.
FS_EVENTS-NAME = C_BEFORE_LINE_OUTPUT.
FS_EVENTS-FORM = C_BEFORE_LINE_OUTPUT.
APPEND FS_EVENTS TO T_EVENTS.
CLEAR FS_EVENTS.
FS_EVENTS-NAME = C_END_OF_LIST.
FS_EVENTS-FORM = C_END_OF_LIST.
APPEND FS_EVENTS TO T_EVENTS.
ENDFORM. " ADD_EVENTS
Form ADD_FIELDCATLOG
This subroutine to append fields to field catlog
No Parameter interface
FORM ADD_FIELDCATLOG.
FS_FIELDCAT-FIELDNAME = 'VTEXT'(006).
FS_FIELDCAT-SELTEXT_L = 'PLANT'(007).
FS_FIELDCAT-OUTPUTLEN = C_30.
FS_FIELDCAT-SELTEXT_M = 'PLANT'(007).
FS_FIELDCAT-SELTEXT_S = 'PLANT'(007).
FS_FIELDCAT-KEY = 'X'.
APPEND FS_FIELDCAT TO T_FIELDCAT.
CLEAR FS_FIELDCAT.
FS_FIELDCAT-FIELDNAME = 'PRDCT'(008).
FS_FIELDCAT-SELTEXT_L = 'PRODUCT'(009).
FS_FIELDCAT-SELTEXT_M = 'PRODUCT'(009).
FS_FIELDCAT-SELTEXT_S = 'PRODUCT'(009).
FS_FIELDCAT-OUTPUTLEN = C_20.
APPEND FS_FIELDCAT TO T_FIELDCAT.
CLEAR FS_FIELDCAT.
FS_FIELDCAT-FIELDNAME = 'QTYA'(010).
FS_FIELDCAT-SELTEXT_L = 'TRUCK'(011).
FS_FIELDCAT-SELTEXT_M = 'TRUCK'(011).
FS_FIELDCAT-SELTEXT_S = 'TRUCK'(011).
APPEND FS_FIELDCAT TO T_FIELDCAT.
CLEAR FS_FIELDCAT.
FS_FIELDCAT-FIELDNAME = 'QTYB'(012).
FS_FIELDCAT-SELTEXT_L = 'RAIL'(013).
FS_FIELDCAT-SELTEXT_M = 'RAIL'(013).
FS_FIELDCAT-SELTEXT_S = 'RAIL'(013).
APPEND FS_FIELDCAT TO T_FIELDCAT.
CLEAR FS_FIELDCAT.
FS_FIELDCAT-FIELDNAME = 'QTYC'(014).
FS_FIELDCAT-SELTEXT_L = 'BARGE'(015).
FS_FIELDCAT-SELTEXT_M = 'BARGE'(015).
FS_FIELDCAT-SELTEXT_S = 'BARGE'(015).
APPEND FS_FIELDCAT TO T_FIELDCAT.
CLEAR FS_FIELDCAT.
FS_FIELDCAT-FIELDNAME = 'QTYD'(016).
FS_FIELDCAT-SELTEXT_L = 'PIPE'(017).
FS_FIELDCAT-SELTEXT_M = 'PIPE'(017).
FS_FIELDCAT-SELTEXT_S = 'PIPE'(017).
APPEND FS_FIELDCAT TO T_FIELDCAT.
CLEAR FS_FIELDCAT.
FS_FIELDCAT-FIELDNAME = 'QTYE'(018).
FS_FIELDCAT-SELTEXT_L = 'VESSEL'(019).
FS_FIELDCAT-SELTEXT_M = 'VESSEL'(019).
FS_FIELDCAT-SELTEXT_S = 'VESSEL'(019).
APPEND FS_FIELDCAT TO T_FIELDCAT.
CLEAR FS_FIELDCAT.
FS_FIELDCAT-FIELDNAME = 'QTYT'(020).
FS_FIELDCAT-SELTEXT_L = 'TOTAL'(021).
FS_FIELDCAT-SELTEXT_M = 'TOTAL'(021).
FS_FIELDCAT-SELTEXT_S = 'TOTAL'(021).
APPEND FS_FIELDCAT TO T_FIELDCAT.
CLEAR FS_FIELDCAT.
FS_FIELDCAT-FIELDNAME = 'QTYG'(022).
FS_FIELDCAT-SELTEXT_L = '32%TOTAL'(023).
FS_FIELDCAT-SELTEXT_M = '32%TOTAL'(023).
FS_FIELDCAT-SELTEXT_S = '32%TOTAL'(023).
APPEND FS_FIELDCAT TO T_FIELDCAT.
CLEAR FS_FIELDCAT.
FS_FIELDCAT-FIELDNAME = 'VRKME'(024).
FS_FIELDCAT-SELTEXT_L = 'UNITS'(025).
FS_FIELDCAT-SELTEXT_M = 'UNITS'(025).
FS_FIELDCAT-SELTEXT_S = 'UNITS'(025).
APPEND FS_FIELDCAT TO T_FIELDCAT.
CLEAR FS_FIELDCAT.
ENDFORM. " ADD_FIELDCATLOG
Regards,
Pavan -
Course of action to performance tune an ALV report
Dear friends,
I am working on an ALV report that needs to be performance tuned.
I have made the following observations about the report.
1) it takes 37 mins to run in production like system
2) there are some nested select statements, which I am trying to get rid of and frame an inner join
3) Most of the data is coming from the tables - knvv,kona,s060,t6b2f.
4) in the st05 - display trace - the fetch S060 table is taking the maximum amount of time
what should be my course of action? Should I create indexes on S060? or request BASIS to create them?
Any other steps I can take to optimize this report.
~thanks for reading, and any feedback is appreciatedHow do i deal with these nested selects
get condition table number(s) based on the condition group for this
rebate - there could be more than one
CLEAR t6b2f.
SELECT kotabnr
FROM t6b2f
INTO t6b2f-kotabnr
WHERE kappl = kona-kappl
AND kobog = kona-kobog.
build condition table name
WRITE t6b2f-kotabnr TO c_kotabnr.
CONCATENATE cond_table_prefix c_kotabnr INTO c_kotabnr.
select all condition numbers for this rebate from this table
SELECT knumh
FROM (c_kotabnr)
INTO my_knumh
WHERE knuma = itab_rebate_info-knuma_item.
for this condition, get lowest scale value and add to purchase req
CLEAR my_kstbw.
SELECT MIN( kstbw )
FROM konw
INTO my_kstbw
WHERE knumh = my_knumh.
itab_rebate_info-kstbw = itab_rebate_info-kstbw + my_kstbw.
see if there is any info in S060 for this condition for the current
rebate's period
CLEAR s060.
SELECT kawrt_k kwert_k auwrt_k
FROM s060
INTO (s060-kawrt_k, s060-kwert_k, s060-auwrt_k)
WHERE knumh = my_knumh
*{ REPLACE TS1K900014 1
*\ AND spmon = itab_rebate_info-spmon.
AND spmon = itab_rebate_info-spmon
AND ssour = ' '
AND vrsio = '000'.
*} REPLACE
accumulate values into internal table fields
itab_rebate_info-kawrt_k = itab_rebate_info-kawrt_k +
s060-kawrt_k.
itab_rebate_info-kwert_k = itab_rebate_info-kwert_k +
s060-kwert_k.
itab_rebate_info-auwrt_k = itab_rebate_info-auwrt_k +
s060-auwrt_k.
CLEAR s060.
ENDSELECT.
ENDSELECT.
ENDSELECT. -
I want to create dynamic ALV report
Hi great abapers,
I want to create dynamic ALV report.Please help me.
Regards,
BillaHi,
Please check the code below:
REPORT YMMR_PALLET_OVERVIEW MESSAGE-ID Y_MESSAGE_0001.
Short description:
To Display and sum up the Quantity of scanned materials on pallet for*
each Shipment number for the Packaging Materials. *
TYPE-POOLS : SLIS.
TABLES: YYLE0003. " Scanned SSCC No.
--Structure Declaration--
Structure for Shipment No. and Date.
TYPES : BEGIN OF T_VTTK_TAB ,
TKNUM LIKE VTTK-TKNUM, " Shipment number
ERDAT LIKE VTTK-ERDAT, " created Date
END OF T_VTTK_TAB .
Structure for Shipment No., Packaging Materials and Date.
TYPES: BEGIN OF T_ITAB2,
TKNUM LIKE YYLE0003-TKNUM, " Shipment number
VHILM LIKE YYLE0003-VHILM, " Packaging Materials
QUANTITY TYPE P,
ERDAT LIKE YYLE0003-ERDAT, " created Date
COUNT TYPE I,
END OF T_ITAB2.
Structure for Shipment No. and Packaging Materials.
TYPES: BEGIN OF T_ITAB3,
TKNUM LIKE YYLE0003-TKNUM, " Shipment number
VHILM LIKE YYLE0003-VHILM, " Packaging Materials
QUANTITY TYPE P, " Quantity
END OF T_ITAB3.
--Internal table Declaration--
*Internal tables for the above Declared structures
DATA: G_VTTK_TAB TYPE TABLE OF T_VTTK_TAB,
G_ITAB5_TAB TYPE TABLE OF T_ITAB2,
G_ITAB4_TAB TYPE TABLE OF T_ITAB3,
G_ITAB3_TAB TYPE TABLE OF T_ITAB2. "#EC NEEDED
*Internal table Holding Shipment No.and quantity
DATA: BEGIN OF G_TOTAL_TAB OCCURS 0 ,
TKNUM TYPE YYLE0003-TKNUM, " Shipment number
QUANTITY TYPE P,
COUNT TYPE I,
END OF G_TOTAL_TAB .
*Internal table for selection screen data
DATA: BEGIN OF G_SCANDATA_TAB OCCURS 0,
VHILM LIKE YYLE0003-VHILM, " Packaging Materials
EXIDV TYPE EXIDV, " External Handling Unit
TKNUM LIKE YYLE0003-TKNUM, " Shipment number
QUANTITY LIKE YYLE0003-QUANTITY, " Quantity
END OF G_SCANDATA_TAB.
DATA: BEGIN OF ST_SCANDATA_TAB,
VHILM LIKE YYLE0003-VHILM, " Packaging Materials
EXIDV TYPE EXIDV, " External Handling Unit
TKNUM LIKE YYLE0003-TKNUM, " Shipment number
QUANTITY LIKE YYLE0003-QUANTITY, " Quantity
END OF ST_SCANDATA_TAB.
DATA: BEGIN OF G_SCANDATA_COUNT_TAB OCCURS 0,
VHILM LIKE YYLE0003-VHILM, " Packaging Materials
TKNUM LIKE YYLE0003-TKNUM, " Shipment number
QUANTITY LIKE YYLE0003-QUANTITY, " Quantity
COUNT TYPE I,
END OF G_SCANDATA_COUNT_TAB.
DATA: L_COUNT TYPE I.
*Internal table for Packaging Materials and quantity
DATA: BEGIN OF G_ITAB6_TAB OCCURS 0,
VHILM LIKE YYLE0003-VHILM, " Packaging Materials
QUANTITY TYPE P, " Quantity
END OF G_ITAB6_TAB.
*- Field catalog
DATA: L_ALV_CAT1_TAB TYPE TABLE OF LVC_S_FCAT.
--Work area Declaration--
DATA: WA_VTTK TYPE T_VTTK_TAB,
WA_ITAB3 TYPE T_ITAB2,
WA_ITAB5 TYPE T_ITAB2,
WA_ITAB4 TYPE T_ITAB3,
WA_ITAB1 LIKE G_SCANDATA_TAB,
WA_ALV_CAT1 LIKE LINE OF L_ALV_CAT1_TAB.
----Variable Defnition -
DATA: G_CUSTOM_CONTAINER_0100 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
G_ALV_GRID_0100 TYPE REF TO CL_GUI_ALV_GRID,
G_CONTAINER_0100 TYPE SCRFNAME VALUE 'LIST',
G_MYLAYOUT TYPE LVC_S_LAYO, "#EC NEEDED
G_WA TYPE REF TO DATA.
DATA: G_VAR TYPE I, " No of records
G_VAR1 TYPE CHAR20. " Variable
--field symbols Declaration--
FIELD-SYMBOLS : <F_FS> TYPE TABLE,
<F_FS3> TYPE ANY,
<F_FS4> TYPE ANY,
<F_FS5> TYPE ANY,
<F_WA> TYPE ANY,
<F_FS15> TYPE ANY,
<F_FS16> TYPE SY-DATUM,
<F_FS2> TYPE T_ITAB2,
<F_FS6> TYPE ANY,
<F_FS7> TYPE ANY,
<F_FS12> TYPE ANY,
<F_FS13> TYPE ANY.
--Selection Parameters--
SELECTION-SCREEN: BEGIN OF BLOCK BLCK01 WITH FRAME TITLE TEXT-000.
"Select options
SELECT-OPTIONS :
S_TKNUM FOR YYLE0003-TKNUM , " Shipment number
S_YYREF FOR YYLE0003-YY_REFERENCE, " Packing reference
S_YYREFT FOR YYLE0003-YY_REFTP, " Reference type
S_EXIDV FOR YYLE0003-EXIDV, " External HU
S_MATNR FOR YYLE0003-MATNR, " Material number
S_VBELN FOR YYLE0003-VBELN, " SD number
S_POSNR FOR YYLE0003-POSNR, " Item number
S_LGTOR FOR YYLE0003-LGTOR, " Door for Wr Hs No
S_VHILM FOR YYLE0003-VHILM, " Packaging Mat
S_YYMEIN FOR YYLE0003-YY_MEINH, " Indicator for UOM
S_QUANTI FOR YYLE0003-QUANTITY, " Quantity
S_YCHECK FOR YYLE0003-YYCHECKED, " Destination_door
S_STATUS FOR YYLE0003-STATUS, " Packing status
S_STASHI FOR YYLE0003-STATUSSHIPTO, " Status on ship-to
S_LOADTR FOR YYLE0003-LOADTRUCK, " Load truck
S_ERDAT FOR YYLE0003-ERDAT , " Date
S_ERZET FOR YYLE0003-ERZET, " Entry time
S_AEDAT FOR YYLE0003-AEDAT, " Last changed on
S_ERNAM FOR YYLE0003-ERNAM, " Name of Person
S_AEZET FOR YYLE0003-AEZET, " Time last change
S_AENAM FOR YYLE0003-AENAM. " Name of person
SELECTION-SCREEN: END OF BLOCK BLCK01.
--INITIALIZATION--
INITIALIZATION.
Clear the variables and workarea
CLEAR :G_VAR,
G_VAR1,
WA_VTTK,
WA_ITAB3,
WA_ITAB5,
WA_ITAB4,
WA_ITAB1,
WA_VTTK,
WA_ITAB3,
WA_ITAB5,
WA_ITAB4,
WA_ITAB1.
--AT SELECTION-SCREEN--
AT SELECTION-SCREEN.
To validate the data entered in selection screen
PERFORM SUB_VALIDATE.
--START-OF-SELECTION--
START-OF-SELECTION.
*To fetch the data from table yyle0003
PERFORM GET_INPUT_DATA.
*To create the Dynamic Field Catalog
PERFORM GET_FIELDCAT.
To populate the data to final table
PERFORM GET_FINAL_DATA.
MODULE status_0100 OUTPUT *
MODULE STATUS_0100 OUTPUT.
*set title bar and PF status.
SET PF-STATUS 'ZVKS'.
SET TITLEBAR 'ZVKS'.
CHECK SY-UCOMM IS INITIAL.
SORT G_SCANDATA_TAB BY TKNUM VHILM.
*Create object for Custom container
CREATE OBJECT G_CUSTOM_CONTAINER_0100
EXPORTING
CONTAINER_NAME = G_CONTAINER_0100
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5.
*Create object for ALV grid
CREATE OBJECT G_ALV_GRID_0100
EXPORTING I_PARENT = G_CUSTOM_CONTAINER_0100.
G_MYLAYOUT-GRID_TITLE = 'Display Scanning data'.
*Call method for table Display
CALL METHOD G_ALV_GRID_0100->SET_TABLE_FOR_FIRST_DISPLAY
CHANGING
IT_OUTTAB = <F_FS>
IT_FIELDCATALOG = L_ALV_CAT1_TAB
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
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.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
User Interaction
MODULE USER_COMMAND_0100 INPUT.
CALL METHOD CL_GUI_CFW=>DISPATCH.
*To exit , back or cancel
CASE SY-UCOMM.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'CANCEL'.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form get_input_data
This sub routine will get the data from yyle0003 table.
FORM GET_INPUT_DATA.
CONSTANTS: C_DOT TYPE C VALUE '.',
C_CHAR TYPE C VALUE 'D'.
CLEAR G_SCANDATA_TAB.
Get the data from yyle0003
SELECT VHILM " Packaging Materials
EXIDV " External Handling Unit
TKNUM " Shipment number
QUANTITY " Quantity
FROM YYLE0003
INTO TABLE G_SCANDATA_TAB
WHERE TKNUM IN S_TKNUM " Shipment number
AND YY_REFERENCE IN S_YYREF " Packing reference
AND YY_REFTP IN S_YYREFT " Reference type
AND EXIDV IN S_EXIDV " External Handling Unit
AND MATNR IN S_MATNR " Material number
AND VBELN IN S_VBELN " SD number
AND POSNR IN S_POSNR " Item number
AND LGTOR IN S_LGTOR " Door for warehouse No
AND VHILM IN S_VHILM " Packaging Materials
AND YY_MEINH IN S_YYMEIN " Indicator for UOM
AND QUANTITY IN S_QUANTI " Quantity
AND YYCHECKED IN S_YCHECK " Destination_door
AND STATUS IN S_STATUS " Packing status
AND STATUSSHIPTO IN S_STASHI " Status on ship-to
AND LOADTRUCK IN S_LOADTR " Load truck
AND ERDAT IN S_ERDAT " Date
AND ERZET IN S_ERZET " Entry time
AND AEDAT IN S_AEDAT " Last changed on
AND ERNAM IN S_ERNAM " Name of Person
AND AEZET IN S_AEZET " Time last change
AND AENAM IN S_AENAM. " Name of person
If VHILM contains any Decimal '.', replace it with D
LOOP AT G_SCANDATA_TAB.
REPLACE C_DOT WITH C_CHAR INTO G_SCANDATA_TAB-VHILM.
IF SY-SUBRC = 0.
MODIFY G_SCANDATA_TAB TRANSPORTING VHILM.
ENDIF.
CLEAR G_SCANDATA_TAB.
ENDLOOP.
*To get the Shipment No Creation date from VTTK.
SELECT TKNUM
ERDAT
FROM VTTK
INTO TABLE G_VTTK_TAB
WHERE TKNUM IN S_TKNUM.
SORT G_SCANDATA_TAB BY VHILM EXIDV. "TKNUM VHILM.
*To get the repeatition of Pacakaging material for each Shipment.
*--- to find the count of packaging materials under each shipment
LOOP AT G_SCANDATA_TAB.
READ TABLE G_SCANDATA_TAB INTO ST_SCANDATA_TAB INDEX SY-TABIX.
AT END OF EXIDV.
L_COUNT = L_COUNT + 1.
MOVE-CORRESPONDING ST_SCANDATA_TAB TO G_SCANDATA_COUNT_TAB.
G_SCANDATA_COUNT_TAB-COUNT = L_COUNT.
CLEAR: ST_SCANDATA_TAB, L_COUNT.
COLLECT G_SCANDATA_COUNT_TAB.
ENDAT.
CLEAR : G_SCANDATA_TAB.
ENDLOOP.
ENDFORM. " get_input_data
*& Form sub_validate
*This subroutine will validate the data eneterd in the selection screen
FORM SUB_VALIDATE.
*Varaiable declaration for Shipment number
DATA: L_TKNUM TYPE YYLE0003-TKNUM."#EC NEEDED " Shipment number
*- Condition will not qualify all primary key (IDENT)
SELECT TKNUM FROM YYLE0003 UP TO 1 ROWS
INTO L_TKNUM "wa_scandata
WHERE TKNUM IN S_TKNUM " Shipment number
AND YY_REFERENCE IN S_YYREF " Packing reference
AND YY_REFTP IN S_YYREFT " Reference type
AND EXIDV IN S_EXIDV " External Handling Unit
AND MATNR IN S_MATNR " Material number
AND VBELN IN S_VBELN " SD number
AND POSNR IN S_POSNR " Item number
AND LGTOR IN S_LGTOR " Door for warehouse No
AND VHILM IN S_VHILM " Packaging Materials
AND YY_MEINH IN S_YYMEIN " Indicator for UOM
AND QUANTITY IN S_QUANTI " Quantity
AND YYCHECKED IN S_YCHECK " Destination_door
AND STATUS IN S_STATUS " Packing status
AND STATUSSHIPTO IN S_STASHI " Status on ship-to
AND LOADTRUCK IN S_LOADTR " Load truck
AND ERDAT IN S_ERDAT " Date
AND ERZET IN S_ERZET " Entry time
AND AEDAT IN S_AEDAT " Last changed on
AND ERNAM IN S_ERNAM " Name of Person
AND AEZET IN S_AEZET " Time last change
AND AENAM IN S_AENAM. " Name of person
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE E987 . " No data found for these selection criterias
ENDIF.
ENDFORM. " sub_validate
*& Form get_fieldcat
Preparing Field catalog
FORM GET_FIELDCAT.
DATA: L_REF TYPE REF TO DATA,
L_I TYPE I. " Variable
CONSTANTS: C_CENTER TYPE C VALUE 'C'. " Center Justified
LOOP AT G_SCANDATA_TAB INTO WA_ITAB1.
MOVE-CORRESPONDING WA_ITAB1 TO WA_ITAB3.
APPEND WA_ITAB3 TO G_ITAB3_TAB.
MOVE-CORRESPONDING WA_ITAB1 TO WA_ITAB4.
COLLECT WA_ITAB4 INTO G_ITAB4_TAB.
*To sum up the qunatity field for each TKNUM.
AT END OF TKNUM.
SUM.
MOVE WA_ITAB1-TKNUM TO G_TOTAL_TAB-TKNUM.
MOVE WA_ITAB1-QUANTITY TO G_TOTAL_TAB-QUANTITY .
APPEND G_TOTAL_TAB.
CLEAR G_TOTAL_TAB.
ENDAT.
CLEAR : WA_ITAB1,
WA_ITAB3,
WA_ITAB4.
ENDLOOP.
*--- Begin of change - SKR.EXT - EBDK986377
SORT G_ITAB4_TAB BY TKNUM.
*--- End of change - SKR.EXT - EBDK986377
LOOP AT G_ITAB4_TAB INTO WA_ITAB4.
MOVE-CORRESPONDING WA_ITAB4 TO WA_ITAB5.
MOVE-CORRESPONDING WA_ITAB4 TO G_ITAB6_TAB.
*---- to get the count
READ TABLE G_SCANDATA_COUNT_TAB WITH KEY TKNUM = WA_ITAB5-TKNUM
VHILM = WA_ITAB5-VHILM.
IF SY-SUBRC EQ 0.
WA_ITAB5-COUNT = G_SCANDATA_COUNT_TAB-COUNT.
ENDIF.
APPEND WA_ITAB5 TO G_ITAB5_TAB.
COLLECT G_ITAB6_TAB.
ENDLOOP.
CLEAR : WA_ITAB3.
SORT G_ITAB4_TAB BY TKNUM VHILM.
DELETE ADJACENT DUPLICATES FROM G_ITAB4_TAB COMPARING VHILM.
*To get the Number of fields to be displayed
DESCRIBE TABLE G_ITAB4_TAB LINES G_VAR.
L_I = '3'.
*Field catalog
WA_ALV_CAT1-FIELDNAME = 'TKNUM'(002).
WA_ALV_CAT1-COL_POS = 1.
WA_ALV_CAT1-COLTEXT ='ShipmentNo.'.
APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
CLEAR : WA_ALV_CAT1.
WA_ALV_CAT1-FIELDNAME = 'ERDAT'(003).
WA_ALV_CAT1-COL_POS = 2.
WA_ALV_CAT1-COLTEXT ='Creation_Date.'(005).
APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
CLEAR : WA_ALV_CAT1.
Create field catalog for each of VHILM
LOOP AT G_ITAB4_TAB INTO WA_ITAB4.
IF G_VAR >= 1.
CONDENSE WA_ITAB4-VHILM NO-GAPS.
WA_ALV_CAT1-FIELDNAME = WA_ITAB4-VHILM. "l_fieldname.
WA_ALV_CAT1-COL_POS = L_I.
WA_ALV_CAT1-COLTEXT = WA_ITAB4-VHILM.
WA_ALV_CAT1-JUST = C_CENTER. "'C'.
APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
CLEAR WA_ALV_CAT1.
L_I = L_I + 1.
ENDIF.
*TOTAL-last column in the field catalog
AT LAST.
WA_ALV_CAT1-FIELDNAME = 'TOTAL'(004).
WA_ALV_CAT1-COL_POS = L_I.
WA_ALV_CAT1-COLTEXT = 'TOTAL'(004).
WA_ALV_CAT1-JUST = C_CENTER. " 'C'.
APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
CLEAR WA_ALV_CAT1.
ENDAT.
SORT L_ALV_CAT1_TAB BY FIELDNAME.
*Non of the field name should not get repeated
DELETE ADJACENT DUPLICATES FROM L_ALV_CAT1_TAB.
ENDLOOP.
SORT L_ALV_CAT1_TAB BY COL_POS.
*Creating Dynamic Internal table
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = L_ALV_CAT1_TAB
IMPORTING
EP_TABLE = L_REF.
Assigning the Dynamic field Catalog to field symbol.
ASSIGN L_REF->* TO <F_FS>.
CREATE DATA G_WA LIKE LINE OF <F_FS>.
ASSIGN G_WA->* TO <F_WA>.
DELETE ADJACENT DUPLICATES FROM <F_FS> COMPARING ALL FIELDS.
ENDFORM. " get_fieldcat
*& Form display_data
FORM GET_FINAL_DATA.
*variable declaration
DATA: L_TOTAL TYPE I, " Row wise total
L_FILL TYPE I, " Count
L_TOT TYPE I. " Grand total
*To get the TOTAL qunatity in the last line of out put.
LOOP AT G_ITAB6_TAB.
CLEAR WA_ITAB5.
WA_ITAB5-TKNUM = 'TOTAL'(004).
WA_ITAB5-ERDAT = SPACE.
MOVE-CORRESPONDING G_ITAB6_TAB TO WA_ITAB5 .
LOOP AT G_SCANDATA_COUNT_TAB WHERE VHILM = G_ITAB6_TAB-VHILM.
WA_ITAB5-COUNT = WA_ITAB5-COUNT + G_SCANDATA_COUNT_TAB-COUNT.
ENDLOOP.
APPEND WA_ITAB5 TO G_ITAB5_TAB.
CLEAR WA_ITAB5.
ENDLOOP.
DESCRIBE TABLE G_ITAB5_TAB LINES L_TOT.
*>>>>>>>>
****To get total qunatity of all TKNUM
LOOP AT G_TOTAL_TAB .
L_TOTAL = L_TOTAL + G_TOTAL_TAB-QUANTITY.
ENDLOOP.
*>>>>>>>>
*To assign ERDAT to g_itab5_tab
LOOP AT G_ITAB5_TAB INTO WA_ITAB5 .
READ TABLE G_VTTK_TAB INTO WA_VTTK WITH KEY TKNUM = WA_ITAB5-TKNUM.
IF SY-SUBRC = 0.
WA_ITAB5-ERDAT = WA_VTTK-ERDAT.
MODIFY G_ITAB5_TAB FROM WA_ITAB5 TRANSPORTING ERDAT.
ENDIF.
ENDLOOP.
*Assigning value in each field to respective Field symbols.
LOOP AT G_ITAB5_TAB ASSIGNING <F_FS2>.
CLEAR G_TOTAL_TAB-QUANTITY.
ASSIGN COMPONENT 'TKNUM' OF STRUCTURE <F_FS2> TO <F_FS6>.
ASSIGN COMPONENT 'TKNUM' OF STRUCTURE <F_WA> TO <F_FS7>.
<F_FS7> = <F_FS6>.
CONDENSE <F_FS2>-VHILM NO-GAPS.
ASSIGN COMPONENT 'VHILM' OF STRUCTURE <F_FS2> TO <F_FS3>.
ASSIGN COMPONENT 5 OF STRUCTURE <F_FS2> TO <F_FS4>.
MOVE <F_FS3> TO G_VAR1.
ASSIGN COMPONENT G_VAR1 OF STRUCTURE <F_WA> TO <F_FS5>.
<F_FS5> = <F_FS4>.
ASSIGN COMPONENT 'ERDAT' OF STRUCTURE <F_FS2> TO <F_FS16>.
ASSIGN COMPONENT 'ERDAT' OF STRUCTURE <F_WA> TO <F_FS15>.
WRITE <F_FS16> TO <F_FS15> .
Inorder not to display the date '00/00/000',
if there is no DATE .
IF ( <F_FS15> CP '00/*' )
OR ( <F_FS15> CP '00.*' )
OR ( <F_FS15> CP '00-*' ).
<F_FS15> = SPACE.
ELSEIF ( <F_FS15> CO ' / /' )
OR ( <F_FS15> CO ' . .' )
OR ( <F_FS15> CO ' - -' ) .
<F_FS15> = SPACE.
ENDIF.
READ TABLE G_TOTAL_TAB WITH KEY TKNUM = <F_FS6>.
IF SY-SUBRC = 0.
ASSIGN G_TOTAL_TAB-QUANTITY TO <F_FS12>.
ASSIGN COMPONENT 'COUNT' OF STRUCTURE <F_FS2> TO <F_FS12>.
ASSIGN COMPONENT 'TOTAL' OF STRUCTURE <F_WA> TO <F_FS13>.
<F_FS13> = <F_FS13> + <F_FS12>.
L_TOTAL = L_TOTAL + <F_FS12>.
ENDIF.
L_FILL = L_FILL + 1.
IF L_FILL = L_TOT.
ASSIGN L_TOTAL TO <F_FS12>.
ASSIGN COMPONENT 'TOTAL' OF STRUCTURE <F_WA> TO <F_FS13>.
<F_FS13> = <F_FS12>.
ENDIF.
AT END OF <F_FS2>-TKNUM.
APPEND <F_WA> TO <F_FS>.
CLEAR <F_WA>.
ENDAT.
ENDLOOP.
CLEAR: <F_FS6>,
<F_FS7>,
<F_WA>.
*Call the screen where Custom container is defined
CALL SCREEN 0100.
ENDFORM. " display_data
Regards
Kannaiah -
Vehicle Retail Sales ALV Report.
Dear ALL,
I am wokring on Vehicle Retail Sales ALV Report.
I have to design Subtotals for Material, Tyre Size/Number of Tyres and SATRP Provision including Grand total.
Till I have develop in zreport --> selection screen for Retail month, Date range and Material and fetching data from database for VBAK and VBAP table by using select query/For all entries.
After that populating all data into final table by using select query and Read statement.
By using Field Catalog populate output display for column position, description field name etc.
Finally Populating out put display by using class cl_gui_alv_grid and method set_table_for_first_display .
Please tell me how to link Tyre Size/charateristic value, Retail Month(VLCADDDATA) and SATRP Provision(xkomv-kschl = 'ZVGT'(Condition Type) with Sales order.
Please reply ASAP
Thanks in advance
Vikas Kumarhiiii....
If you are using field catalog use ..... a function module "REUSE_ALV_LIST_DISPLAY"
and ...you can get subtotals by .. sort the individual fields ..and by enabling an option in Is_layout .... inporting parameter of the FM
or
IF you are using object oriented ALV
in cl_gui_alv_display class.... you have a method for sorting ...... you have to call that method .... after that....you can get subtotal for the field you want ....with the sort///
and
u can link the parameters .... all together with sort .. -
In ALV Report Filter selection should be case sensitive
Dear All,
since one field is case sensitive in database table , i have to fetch that in alv report , but when i am applying filter on that field its is simply fetching data with case description. if its in caps it should fetch caps data but in smaal case report showing no data
Regards,
Pankaj VashistaHi,
All text datas are case sensitive.
To make it work perfectly You have to Use the Keyword translate to Upper Case than display
Now filter can work.
Without Transalation to Upper Case filter will not work.
Regards
Arbind -
Hi Expart,
In ALV report ,what is the work of
1) REUSE_ALV_VARIANT_DEFAULT_GET function module
2) SLIS_LAYOUT_ALV
Regards
BhabaniHi,
1.SELECTING THE VARIANTS FOR INITIAL LIST DISPLAY (DEFAULT VARIANT)
The variants in the list display can be both user-specific and general. The user can programmatically set the initial (default) variant for list display.
The default variant can be found using the function module 'REUSE_ALV_VARIANT_DEFAULT_GET'.
Sample code:
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = variant save condition ( A=all, U = user-specific )
CHANGING
cs_variant = internal table containing the program name (and the default variant---optional )
EXCEPTIONS
not_found = 2.
2.A layout is build for the report output list description USING the internal table declared above (I_LAYOUT).
Output list description structure.
The parameters are described under the following heads:
Display options
Exceptions
Totals
Interaction
Detail screen
Display variants (only for hierarchical-sequential lists)
Color
Other
The layout table is of type slis_layout_alv_spec and has the following fields:
Reward,if useful.
Thanks,
Chandu -
Column Heading are not displayed in ALV Report using CL_SALV_DISPLAY?
Hi,
I am using CL_SALV_DISPLAY class to display data. I Created an Internal Table Dynamically based fieldcatalog which was prepared based data at run time. When i displayed data using CL_SALC_DISPALY data is display in output but column headings are not displayed.
can anyone suggest me how to display heading in ALV using CL_SALV_DISPLAY class, My code is
CLASS lcl_report DEFINITION
CLASS lcl_report DEFINITION.
PUBLIC SECTION.
METHODS:
display IMPORTING l_table TYPE string
l_fcat TYPE string.
ENDCLASS. "lcl_report DEFINITION
CLASS lcl_report IMPLEMENTATION
CLASS lcl_report IMPLEMENTATION.
METHOD display.
DATA: gr_table TYPE REF TO cl_salv_table.
DATA: gr_columns TYPE REF TO cl_salv_columns_table,
gr_column TYPE REF TO cl_salv_column_table,
ls_fcat TYPE slis_fieldcat_alv.
DATA: gr_display TYPE REF TO cl_salv_display_settings.
DATA: l_o_functions TYPE REF TO cl_salv_functions_list,
l_field TYPE string.
FIELD-SYMBOLS : <fs_table> TYPE STANDARD TABLE,
<ft_fcat> TYPE STANDARD TABLE.
Get the ALV object refering to the output table
ASSIGN (l_table) TO <fs_table>.
ASSIGN (l_fcat) TO <ft_fcat>.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = <fs_table> ).
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
Add basic default functionality in the ALV report
Functions
l_o_functions = gr_table->get_functions( ).
l_o_functions->set_all( abap_true ).
gr_columns = gr_table->get_columns( ).
gr_columns->set_headers_visible( abap_true ).
Display the list
gr_table->display( ).
ENDMETHOD. "extract
ENDCLASS. "lcl_report IMPLEMENTATION
*& start-of-selection declaration
START-OF-SELECTION.
PERFORM :
get store codes
get_storecodes USING p_stfile
CHANGING it_t001w,
fetching mard data
read_mard_data,
preparing fieldcatalog for Final Data
create_filedcat USING it_t001w
it_site
CHANGING it_fieldcat,
preparing structure & internal table for Final Data
create_final_table_structure USING it_fieldcat,
prepare output data
prepare_final_data.
*& end-of-selection declaration
END-OF-SELECTION.
PERFORM :
display data
display_data USING l_table
l_fcat.
*& Form get_storecodes
FORM get_storecodes USING p_p_stfile
CHANGING p_it_t001w LIKE it_t001w[].
DATA :
internal table for RAW
lt_raw TYPE truxs_t_text_data,
rs_site LIKE LINE OF rt_site,
l_index LIKE sy-tabix.
FIELD-SYMBOLS :
field symbol for it_t001w
<fs_t001w> LIKE LINE OF p_it_t001w.
calling function module to get Stores Data from File
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_line_header = 'X'
i_tab_raw_data = lt_raw
i_filename = p_p_stfile
TABLES
i_tab_converted_data = p_it_t001w[]
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
EXIT.
ENDIF.
SORT p_it_t001w BY werks.
CLEAR rs_site.
rs_site-sign = 'I'.
rs_site-option = 'EQ'.
rs_site-low = p_dccode.
APPEND rs_site TO rt_site.
IF it_t001w[] IS NOT INITIAL.
LOOP AT p_it_t001w ASSIGNING <fs_t001w>.
l_index = sy-tabix.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = <fs_t001w>-werks
IMPORTING
output = <fs_t001w>-werks.
MODIFY p_it_t001w FROM <fs_t001w> INDEX l_index.
IF <fs_t001w>-werks GE s_site-low AND <fs_t001w>-werks LE s_site-high.
append site to ranges
CLEAR rs_site.
rs_site-sign = 'I'.
rs_site-option = 'EQ'.
rs_site-low = <fs_t001w>-werks.
APPEND rs_site TO rt_site.
CONTINUE.
ENDIF.
ENDLOOP.
SORT p_it_t001w BY werks.
SORT rt_site.
ENDIF.
ENDFORM. " get_storecodes
*& Form create_final_table_structure
FORM create_filedcat USING p_it_t001w LIKE it_t001w[]
p_it_site LIKE it_site[]
CHANGING p_it_fieldcat LIKE it_fieldcat[].
FIELD-SYMBOLS :
field symbol for p_it_t001w
<fs_t001w> LIKE LINE OF p_it_t001w,
field symbol for p_it_site
<fs_site> LIKE LINE OF p_it_site.
DATA :
fieldname
l_fieldname TYPE slis_fieldname,
workarea for site ranges
rs_site LIKE LINE OF rt_site.
CLEAR : l_fieldname, rs_site.
l_fieldname = p_dccode.
PERFORM
prepare fieldcatalog
build_fieldcatalog USING : 'MTART' 'CHAR' '5' ,
'MTBEZ' 'CHAR' '25' ,
'MATKL' 'CHAR' '6' ,
'WGBEZ' 'CHAR' '20' ,
'MATNR' 'CHAR' '18' ,
'MAKTX' 'CHAR' '30' ,
l_fieldname 'CHAR' '17' .
create header for excel
PERFORM create_excel_header USING : 'Division',
'Divsion Description',
'MC Code',
'MC Description',
'Article',
'Article Description',
l_fieldname.
loop for creating fieldcatalog
LOOP AT it_site ASSIGNING <fs_site>.
READ TABLE it_t001w ASSIGNING <fs_t001w> WITH KEY werks = <fs_site>-werks
BINARY SEARCH.
IF sy-subrc = 0 AND <fs_t001w> IS ASSIGNED AND
<fs_site> IS ASSIGNED AND <fs_site>-stock GT 0.
CLEAR : l_fieldname, rs_site.
l_fieldname = <fs_site>-werks.
prepare fieldcatalog
PERFORM build_fieldcatalog USING : l_fieldname 'CHAR' '17'.
create header for excel
PERFORM create_excel_header USING l_fieldname .
CONTINUE.
ENDIF.
ENDLOOP.
l_fcat = 'it_fieldcat[]'.
ENDFORM. " create_final_table_structure
*& Form build_fieldcatalog
FORM build_fieldcatalog USING p_fieldname TYPE slis_fieldname
p_datatype TYPE datatype_d
p_length TYPE intlen.
DATA : ls_fieldcat LIKE LINE OF it_fieldcat.
CLEAR : ls_fieldcat.
ls_fieldcat-fieldname = p_fieldname.
ls_fieldcat-datatype = p_datatype.
ls_fieldcat-intlen = p_length.
APPEND ls_fieldcat TO it_fieldcat.
ENDFORM. " build_fieldcatalog
*& Form create_final_table_structure
FORM create_final_table_structure USING p_it_fieldcat.
Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = t_table.
ASSIGN t_table->* TO <ft_final>.
ENDFORM. " create_final_table_structure
*& Form create_excel_header
FORM create_excel_header USING p_p_fieldname.
DATA : ls_header LIKE LINE OF it_header.
CLEAR ls_header.
ls_header-col_name = p_p_fieldname.
APPEND ls_header TO it_header.
ENDFORM. " create_excel_header
*& Form prepare_final_data
FORM prepare_final_data .
DATA : l_matnr LIKE g_matnr,
l_werks LIKE g_werks,
l_index LIKE sy-tabix.
FIELD-SYMBOLS : <fs_mard> LIKE LINE OF it_mard.
Getting No. of Lines in IT_MARD internal table
DESCRIBE TABLE it_mard LINES g_lines.
LOOP AT it_mard ASSIGNING <fs_mard>.
l_index = sy-tabix.
IF l_matnr IS INITIAL.
l_matnr = <fs_mard>-matnr.
CLEAR : l_werks.
l_werks = <fs_mard>-werks.
UNASSIGN : <fs_value>, <fs_final>.
Create dynamic work area and assign to FS
CREATE DATA t_line LIKE LINE OF <ft_final>.
ASSIGN t_line->* TO <fs_final>.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_mard>-matnr.
ASSIGN COMPONENT l_werks OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_value> + <fs_mard>-labst.
getting Article Type,MC & its Descriptions
PERFORM get_other_data USING l_matnr
l_werks.
ELSEIF l_matnr <> <fs_mard>-matnr.
APPEND <fs_final> TO <ft_final>.
CLEAR l_matnr.
l_matnr = <fs_mard>-matnr.
CLEAR : l_werks.
l_werks = <fs_mard>-werks.
UNASSIGN : <fs_value>, <fs_final>.
Create dynamic work area and assign to FS
CREATE DATA t_line LIKE LINE OF <ft_final>.
ASSIGN t_line->* TO <fs_final>.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_mard>-matnr.
ASSIGN COMPONENT l_werks OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_value> + <fs_mard>-labst.
getting Article Type,MC & its Descriptions
PERFORM get_other_data USING l_matnr
l_werks.
ELSE.
CLEAR : l_werks.
l_werks = <fs_mard>-werks.
ASSIGN COMPONENT l_werks OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_value> + <fs_mard>-labst.
ENDIF.
IF l_index = g_lines.
APPEND <fs_final> TO <ft_final>.
ENDIF.
ENDLOOP.
l_table = '<ft_final>[]'.
ENDFORM. " prepare_final_data
*& Form get_other_data
FORM get_other_data USING p_l_matnr
p_l_werks.
FIELD-SYMBOLS : <fs_mara> LIKE LINE OF it_mara,
<fs_t023t> LIKE LINE OF it_t023t,
<fs_t134t> LIKE LINE OF it_t134t,
<fs_makt> LIKE LINE OF it_makt.
READ TABLE it_mara ASSIGNING <fs_mara> WITH KEY matnr = p_l_matnr. " BINARY SEARCH.
IF sy-subrc = 0 AND <fs_mara> IS ASSIGNED.
ASSIGN COMPONENT 'MTART' OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_mara>-mtart.
ASSIGN COMPONENT 'MATKL' OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_mara>-matkl.
READ TABLE it_makt ASSIGNING <fs_makt> WITH KEY matnr = <fs_mara>-matnr BINARY SEARCH.
IF sy-subrc = 0 AND <fs_makt> IS ASSIGNED.
ASSIGN COMPONENT 'MAKTX' OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_makt>-maktx.
ENDIF.
READ TABLE it_t023t ASSIGNING <fs_t023t> WITH KEY matkl = <fs_mara>-matkl BINARY SEARCH.
IF sy-subrc = 0 AND <fs_t023t> IS ASSIGNED.
ASSIGN COMPONENT 'WGBEZ' OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_t023t>-wgbez.
ENDIF.
READ TABLE it_t134t ASSIGNING <fs_t134t> WITH KEY mtart = <fs_mara>-mtart BINARY SEARCH.
IF sy-subrc = 0 AND <fs_t134t> IS ASSIGNED.
ASSIGN COMPONENT 'MTBEZ' OF STRUCTURE <fs_final> TO <fs_value>.
<fs_value> = <fs_t134t>-mtbez.
ENDIF.
ENDIF.
ENDFORM. " get_other_data
*& Form display_data
text
FORM display_data USING p_l_table
p_l_fcat.
DATA:
Variable for Object Creation
o_report TYPE REF TO lcl_report.
CREATE OBJECT o_report.
o_report->display( EXPORTING l_table = p_l_table
l_fcat = p_l_fcat ).
ENDFORM. " display_dataI don't know how to read the code you pasted or I would have checked this myself.
Do your fields in the internal table reference dictionary objects or elementary types? If not using dictionary types, the column names will be blank by default. If you can't change your fields to be dictionary types, you can try this to change the column names:
I made a method inside my local class to add the names:
call method set_colname
EXPORTING iv_tab = alv_tab
iv_colid = 'xxxx' "fieldname from the table
iv_stxt = text-t54
iv_mtxt = text-t55
iv_ltxt = text-t55.
METHOD set_colname .
data:
alv_cols type REF TO cl_salv_columns_table,
alv_col type REF TO cl_salv_column.
TRY .
*... Change fieldnames
call METHOD iv_tab->get_columns RECEIVING value = alv_cols.
call method alv_cols->get_column EXPORTING columnname = iv_colid RECEIVING value = alv_col.
IF iv_stxt <> ''.
CALL METHOD alv_col->set_short_text EXPORTING value = iv_stxt.
ENDIF.
IF iv_mtxt <> ''.
CALL METHOD alv_col->set_medium_text EXPORTING value = iv_mtxt.
ENDIF.
IF iv_ltxt <> ''.
CALL METHOD alv_col->set_long_text EXPORTING value = iv_ltxt.
ENDIF.
CATCH cx_salv_not_found.
ENDTRY.
ENDMETHOD. "set_colname -
ALV Report performance & export problem
Hi,
We have developed an complex ALV report which accesses the data from FI Tables like BKPF, BSEG, BSAK etc., There are almost 100 lac records in BSEG and every day around 20000 records are getting added to that. Eventhough I have used specific search criteria, system is taking lot of time. Due to this I forced to run the report in background. In background also it is taking around 4 - 6 hours.
1) How can I improve the performance of the report. Especially to access data from huge database table like BSEG with lot of conditions. Any best practices
2) I want to have an option (at selection screen) to get the report directly saved in a Excel file at desired path.
Please help me.
Thanks in advance,
MallikHi Mallik,
Already i faced this problem before. At that time i follow some precuations:
1) Check the estimation cost for that report with the basis people.
2) The selection fields mentionedin the select statement and fields order in the internal; table should match with order of Data base fields order.
3) Define type statements and then refer internal table to that types.
4) Define secondary indexes in the where condition properly.
5) Add BINARY SEARCH to read table statement.
6) if possible attach package size n to the select statement.
7) Avoid nested loops and nested selects.
8) After populating the final internal table free all the internal tables.
9) check how much time taking for each select statemnt through SY05.
Hope this helps you. reply for queries.
Regards,
Kumar. -
How to call an alv report from another program and return back
Hello ,
I am calling one abap program (Prgm B) from another program (Prgrm A).
Here, Prgm B is an ALV report. I have fetch some data from Prgem B that gets stored in an internal table.
Now, I am using below code in Prgrm A,
SUBMIT Prgrm B VIA SELECTION-SCREEN
WITH SELECTION-TABLE rspar
EXPORTING LIST TO MEMORY
AND RETURN.
When Prgrm A executed, it lead me to selection screen of Prgrm B and when I click F8, it shows me the report output, In short, it doesnt return back to Prgrm A. It ends up showing me the alv report if Prgrm B even afetr using RETURN statement.
I want to get back to Prgrm A by fetching some data from Prgrm B.
Please let me know, if i am missing something.
Regards,
SeemaHi Seema,
Refer below code.
DATA: v_matnr LIKE mara-matnr.
DATA: t_listobject TYPE abaplist OCCURS 0 WITH HEADER LINE.
DATA: t_mara TYPE mara OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF t_ascilist OCCURS 0,
line(200).
DATA: END OF t_ascilist.
data var(3) type c.
SELECT-OPTIONS: s_matnr FOR v_matnr.
var = ' 3'.
START-OF-SELECTION.
SUBMIT ztestaks1 WITH s_matnr IN s_matnr EXPORTING LIST TO MEMORY
AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = t_listobject
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.
ELSE.
CALL FUNCTION 'LIST_TO_ASCI'
* EXPORTING
* LIST_INDEX = -1
* WITH_LINE_BREAK = ' '
TABLES
listasci = t_ascilist
listobject = t_listobject
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.
WRITE:/ 'Below are the lines from the submitted program.'.
LOOP AT t_ascilist.
WRITE:/ t_ascilist-line.
ENDLOOP.
SKIP 2.
ENDIF.
ENDIF.
IMPORT t_mara FROM MEMORY ID 'T_MARA'.
WRITE:/
'Here is the output from the table exported from the submitted program.'
LOOP AT t_mara.
WRITE:/ t_mara-matnr.
ENDLOOP.
Submitted program
REPORT ZTESTAKS1.
DATA: v_matnr LIKE mara-matnr,
v_maktx LIKE makt-maktx.
DATA: t_mara TYPE mara OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF t_makt OCCURS 0,
matnr LIKE makt-matnr.
DATA: END OF t_makt.
SELECT-OPTIONS: s_matnr FOR v_matnr,
s_maktx FOR v_maktx.
START-OF-SELECTION.
SELECT matnr INTO TABLE t_makt
FROM makt
WHERE matnr IN s_matnr
AND maktx IN s_maktx.
if not t_makt[] is initial.
SELECT * FROM mara
INTO TABLE t_mara FOR ALL ENTRIES IN t_makt
WHERE matnr = t_makt-matnr.
endif.
EXPORT t_mara TO MEMORY ID 'T_MARA'.
WRITE:/ 'This list is from the submitted program'.
SKIP 1.
LOOP AT t_mara.
WRITE:/ t_mara-mtart.
ENDLOOP.
Hopes this helps you.
Thanks,
Ashok. -
How to insert horizontal lines in alv report?
hi,
i have to insert horizontal lines in alv report.( RM07MLBB )
actually my requirement is:
basis list = RM07MLBB.
first secondary list = another report is called here ( RM07DOCS )
i want to insert horizontal lines in the first secondary list, when i execute individually RM07DOCS , i can get horizontal lines, but when i dounle click in the basic list --> in the first secondary list , i am not getting the horizontal lnes.
functional modules used are REUSE_ALV_HIERSEQ_LIST_DISPLAY & REUSE_ALV_GRID_DISPLAY.
here in this program,
is_layout = alv_layout.
hence i tried to give
alv_layout-no_hline = ' '.
but not effecting.
can some one please tell me , how to insert lines in the alv report.
thanks in advance,
Dastagir.hello,
so i cannot insert horizontal lines in the first secondary list according to my sorting condition, i.e., in a single block there should be :
if same delivery challan number is repeating they should come in the same block,
for the corresponding delivery challen number, if have po number, is repeating , they also should come in the same block.
in this way i have to seperate the blocks containing EXNUM , EBELN CONDITIONED.
Maybe you are looking for
-
My wifi and bluetooth are no longer active
my wifi and bluetooth are no longer active .Does anyone could help me? already gave reset and nothing.
-
TS3988 How to cancel iCloud storage upgrade within 15 days
Misunderstood the whole storage thing, and want to cancel.
-
"recording stopped because the format of the source media changed"
I just got this error was trying to use quicktime to capture a video was able to capture another video successfully but for some reason it doesn't like this tape even though it was recorded on the same machine any thoughts?
-
Email sends on one but not the other laptop
I have both a MBP and a MB with the same work email address set up identically on both. Both have been used to send and receive email with no problem until last night. Suddenly I cannot send email on the MB. Here's details: I'm using my work email -
-
Keep getting error message 4310 when trying to burn music from playlist onto CD. How can I fix this for free?