Authorization of alv report based on plants
I have created a new alv report for sale order statement.The problem is which can be seen in all plants
irespective of the user.Suppose our company has 5 palnt
Plant 1100 to 1500
The problem is suppose a user he has only rights in a prticular plant but he can see all the palnt sale order details
How can we authorize this particular alv report based on the plants
Hello,
My assumption: You have Company Code(T001-BUKRS) in the selection-screen.
Plz check the code snippet below:
DATA:
IT_PLANT TYPE STANDARD TABLE OF WERKS,
WA_PLANT LIKE LINE OF IT_PLANT.
DATA:
IT_R_WERKS TYPE RANGE_T_WERKS_D,
R_WERKS TYPE RANGE_S_WERKS_D.
SELECT BWKEY INTO TABLE IT_PLANT
FROM T001K
WHERE BUKRS = '1000'. "--> Here you have to use your sel. scr. parameter
IF SY-SUBRC = 0.
SORT IT_PLANT BY WERKS.
ENDIF.
LOOP AT IT_PLANT INTO WA_PLANT.
* Check the authority for the plant
AUTHORITY-CHECK OBJECT 'M_MSEG_WMB'
ID 'ACTVT' FIELD '03'
ID 'WERKS' FIELD WA_PLANT-WERKS.
IF SY-SUBRC = 0.
R_WERKS-SIGN = 'I'.
R_WERKS-OPTION = 'EQ'.
R_WERKS-LOW = WA_PLANT-WERKS.
APPEND R_WERKS TO IT_R_WERKS.
CLEAR R_WERKS.
ENDIF.
ENDLOOP.
IF IT_R_WERKS IS NOT INITIAL.
"Select data using the Plants for which user is authorised
ELSE.
"User has no authority to display any Plant data
ENDIF.
Hope this is of some help to you.
BR,
Suhas
Edited by: Suhas Saha on Mar 18, 2009 10:18 AM
Similar Messages
-
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. -
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 -
Authorization chaeck in report based on Table
My client want report to be displayed based on the Authorization. For example when user is entering Input parameters like Plant, Sales org. and executing the report it should check for the Authorization of the user for that plant and Sales org.
the reason being they don't want to allow other division to see the important data of that report. As this report is used by all the division and i can not put check in Role assignment as many of the roles are there with same t-code of report and where plant and sales org is mentioned as * in that roles.
i want to put check based on ABAP coding and write with the help of Table and Field in order to Check the Authorization of Plant and sales org for that particular USER PROFILE.
Bacause changing in the profile will have huge effect on the report functionality as this reoprt is used in ALL over india level and our client Business spread all over iNdia Level.
If anybody know how to do that can help alot.hi,
Check the foll.:
AUTHORITY-CHECK OBJECT object ID name1 FIELD f1
Explanation of IDs:
object
Field which contains the name of the object for which the authorization is to be checked.
name1 ...
Fields which contain the names of the
f1 ...
Fields which contain the values for which the
AUTHORITY-CHECK checks for one object whether the user has an authorization that contains all values of f.
Create an object say, z_auth with auth fields as plant(WERKS), Sales Org(VKORG) etc..whatever is relevant.
Now, in ur report, U can write..
say, pa_plant is a parameter in ur seln screen.
AUTHORITY-CHECK OBJECT 'ZAUTH'
ID 'WERKS' FIELD pa_plant.
IF sy-subrc NE 0.
"No authorization for plant <pa_werks>"
MESSAGE exxx WITH pa_plant.
ENDIF.
I hope this helps.
Plz Reward suitable points, if it helps.
Rgds,
Raghu. -
Subtotal in alv report based on the particular field value
Hi,
As per my requirement, i need to do subtotal of quntity field based on the material number field value in alv report.
Ex: if material number falls 1 to 10 then i need to be calculate and display subtotal qty amount with text " total of the mat1" and if material number falls 11 to 20 then again i need to be claculate and display subtotal qty amount with text "total of the mat2". similarily i need to display the details.
<removed_by_moderator>
Regards
NagendraHi,
Ex: if material number falls 1 to 10 then i need to be calculate and display subtotal qty amount with text " total of the mat1" and if material number falls 11 to 20 then again i need to be claculate and display subtotal qty amount with text "total of the mat2". similarily i need to display the details.
What you can do is in your output table, you will have to create an auxilary field, lets call it as material group (groupid). Now you can do a subtotal on the material group. However the logic to determine what materials belong to which group should be coded. I guess you might be having some logic for that.
So lets say that material 1 to 10 as G1 ( group 1 ) and material 11 to 20 as G2 ( group 2 )
The output of the internal table would be
Groupid matnr ...
1 1
1 2
1 3.....and so on
2 11
2 12
2 13....upto 20.
Now in the fieldcatalog assign an 'X' to the 'dosum' parameter to the field Groupid
In the sort info do the following :
gs_sort-fieldname = 'GROUPID'.
gs_sort-spos = 1.
gs_sort-up = 'X'.
gs_sort-subtot = 'X'. ***CRUCIAL STATEMENT****
append gs_sort to gt_sort.
Now pass all this data to the alv grid function. And you are done.
regards,
Advait -
Hi everyone,
i have a requirement that
when i enter the plant number, material number, MRP element version, and range of date starting from today date till the date - it should provide the output this way.
Material leadtime Satety stock available quantity -(for the range of dates)
27/8 28/8 29/8 so on
eg.BMR168345 7 8000 1650 1350 1350 ....
on 28th there is order for 300 elements so it is 1350
It is a report based on MD04 transaction.Hello,
My assumption: You have Company Code(T001-BUKRS) in the selection-screen.
Plz check the code snippet below:
DATA:
IT_PLANT TYPE STANDARD TABLE OF WERKS,
WA_PLANT LIKE LINE OF IT_PLANT.
DATA:
IT_R_WERKS TYPE RANGE_T_WERKS_D,
R_WERKS TYPE RANGE_S_WERKS_D.
SELECT BWKEY INTO TABLE IT_PLANT
FROM T001K
WHERE BUKRS = '1000'. "--> Here you have to use your sel. scr. parameter
IF SY-SUBRC = 0.
SORT IT_PLANT BY WERKS.
ENDIF.
LOOP AT IT_PLANT INTO WA_PLANT.
* Check the authority for the plant
AUTHORITY-CHECK OBJECT 'M_MSEG_WMB'
ID 'ACTVT' FIELD '03'
ID 'WERKS' FIELD WA_PLANT-WERKS.
IF SY-SUBRC = 0.
R_WERKS-SIGN = 'I'.
R_WERKS-OPTION = 'EQ'.
R_WERKS-LOW = WA_PLANT-WERKS.
APPEND R_WERKS TO IT_R_WERKS.
CLEAR R_WERKS.
ENDIF.
ENDLOOP.
IF IT_R_WERKS IS NOT INITIAL.
"Select data using the Plants for which user is authorised
ELSE.
"User has no authority to display any Plant data
ENDIF.
Hope this is of some help to you.
BR,
Suhas
Edited by: Suhas Saha on Mar 18, 2009 10:18 AM -
Authorization for running report based on Remote Cube
Hi ,
I have created a report based on Remote cube in BI 7.0
I have created a DTP with Direct access to load the Remote cube.
While running the report based on Remote cube , I am getting error
'You are not authorized for the DTP '
The report is running only when I assign the '*' value to the authorization objects for the role in which the report is stored:
S_RS_DTP = * (For DTP)
S_RS_TR = * (For Transformation)
S_RS_DS = * (For datasource)
I want to restrict the values to the objects related to my report only rather than * which means ALL.
Please help what values to assign for these authorization objects for the Role.
Thanks.Hi,
You need to make necessary settings in RSECADMIN for the Authorization Objects. The default values will be * . You have to customize them to suit your requirement.
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/101fb4f5-eb7c-2c10-5daa-b479c47f0a14
Regards,
Suman -
Authorizations for WEBI report based on BPC data model
Hi All,
We are strugelling with setting up authorisations for the reporting on BPC data model.
We created Bex query on top of Multiprovider that consists of BPC cube. The Bex query is source for WEBI output. The authorisations has been set up on BPC data model (cube) in BPC application but they are not passed nor to Bex query nor to Webi. Example: The query is build on top of OPEX BPC data model, this data model is restricted based on Oranizational Unit. My test user is allowed to see only Org Unit = 'Australia' in the OPEX BPC data model, however when I'm running the report I can see absolutely everything.
We are not connecting/using any BI cubes itself for this reporting. We are intrested only in the WEBI report based on BPC data models.
We were trying to use BPC data model (without any extra settings) as the source for BEx report, we were also trying to use virtual BPC data model as the source for Bex transient query - but non of these have helped.
Can you please advise how the authorisations should be set up for WEBI reporting on BPC data models?
KasiaAnybody can help with this issue please?
-
ALV Report for Purchasing Each Vendor
Hi Anybody,
I am developing Purchasing Report. But I want display records in ALV Report based Vendor ID and Name.
Like Standard Report ME2M.
Ex:
Vendor ID : A0002 Name : UMS SEMICONDUCTOR PTE LTD.,
sNO po no item Price Qty
1. 10001 10 12.30 10
2. 10002 20 30.30 50
3. 10003 30 40.30 150
Vendor ID : X0012 Name : ALPHA PTE LTD.,
sNO po no item Price Qty
1. 10004 10 1.30 10
2. 10005 20 50.30 50
3. 10006 30 620.30 150
How to I will do?. Anybody please tell me.
Tks
S.Muthu.
IT Dept.hi..follow this code..
===================================================================
===================================================================
report .
========================== Global definitions ====================
Data Types
type-pools: slis.
types: begin of tp_data,
lifnr like ekko-lifnr,
end of tp_data,
tp_tbl_data type standard table of tp_data.
Constants
Data objects (variable declarations and definitions)
Report data to be shown.
data: it_data type standard table of tp_data.
Heading of the report.
data: t_heading type slis_t_listheader.
======================= Selection Screen ==========================
selection-screen: begin of block b1 with frame title text-t01.
DATA: w_aux_lifnr like ekko-lifnr.
SELECT-OPTIONS s_lifnr for w_aux_lifnr
DEFAULT LIFNR .
selection-screen: end of block b1.
======================== Event Blocks =============================
at selection-screen.
start-of-selection.
perform get_data using it_data.
end-of-selection.
perform build_alv using it_data t_heading.
======================== Subroutines ==============================
*& Form get_data
Gets the information to be shown in the report.
form get_data using t_data type tp_tbl_data.
SELECT ekko~lifnr
INTO CORRESPONDING FIELDS OF TABLE t_data
FROM ekko as ekko
WHERE ekko~lifnr in s_lifnr
endform. " get_data
*& Form build_alv
Builds and display the ALV Grid.
form build_alv using t_data type tp_tbl_data
t_heading type slis_t_listheader.
ALV required data objects.
data: w_title type lvc_title,
w_repid type syrepid,
w_comm type slis_formname,
w_status type slis_formname,
x_layout type slis_layout_alv,
t_event type slis_t_event,
t_fieldcat type slis_t_fieldcat_alv,
t_sort type slis_t_sortinfo_alv.
refresh t_fieldcat.
refresh t_event.
refresh t_sort.
clear x_layout.
clear w_title.
Field Catalog
perform set_fieldcat2 using:
1 'LIFNR' 'LIFNR' 'EKKO' space space space space space space space space space space space space t_fieldcat .
Layout
x_layout-zebra = 'X'.
Top of page heading
perform set_top_page_heading using t_heading t_event.
Events
perform set_events using t_event.
GUI Status
w_status = ''.
w_repid = sy-repid.
Title
w_title = <<If you want to set a title for
the ALV, please, uncomment and edit this line>>.
User commands
w_comm = 'USER_COMMAND'.
Order
Example
PERFORM set_order USING '<field>' 'IT_DATA' 'X' space space t_sort.
Displays the ALV grid
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = w_repid
it_fieldcat = t_fieldcat
is_layout = x_layout
it_sort = t_sort
i_callback_pf_status_set = w_status
i_callback_user_command = w_comm
i_save = 'X'
it_events = t_event
i_grid_title = w_title
tables
t_outtab = t_data
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " build_alv.
*& Form set_top_page_heading
Creates the report headings.
form set_top_page_heading using t_heading type slis_t_listheader
t_events type slis_t_event.
data: x_heading type slis_listheader,
x_event type line of slis_t_event.
Report title
clear t_heading[].
clear x_heading.
x_heading-typ = 'H'.
x_heading-info = ''(001).
append x_heading to t_heading.
Program name
clear x_heading.
x_heading-typ = 'S'.
x_heading-key = 'Program: '.
x_heading-info = sy-repid.
append x_heading to t_heading.
User who is running the report
clear x_heading.
x_heading-typ = 'S'.
x_heading-key = 'User: '.
x_heading-info = sy-uname.
append x_heading to t_heading.
Date of execution
clear x_heading.
x_heading-typ = 'S'.
x_heading-key = 'Date: '.
write sy-datum to x_heading-info.
append x_heading to t_heading.
Time of execution
clear x_heading.
x_heading-typ = 'S'.
x_heading-key = 'Time: '.
write sy-uzeit to x_heading-info.
append x_heading to t_heading.
Top of page event
x_event-name = slis_ev_top_of_page.
x_event-form = 'TOP_OF_PAGE'.
append x_event to t_events.
endform.
*& Form set_events
Sets the events for ALV.
The TOP_OF_PAGE event is alredy being registered in
the set_top_page_heading subroutine.
form set_events using t_events type slis_t_event.
data: x_event type line of slis_t_event.
Example
clear x_event.
x_event-name = .
x_event-form = .
append x_event to t_event.
endform.
*& Form set_order
Adds an entry to the order table.
FORM set_order USING p_fieldname p_tabname p_up p_down p_subtot
t_sort TYPE slis_t_sortinfo_alv.
DATA: x_sort TYPE slis_sortinfo_alv.
CLEAR x_sort.
x_sort-fieldname = p_fieldname.
x_sort-tabname = p_tabname.
x_sort-up = p_up.
x_sort-down = p_down.
x_sort-subtot = p_subtot.
APPEND x_sort TO t_sort.
ENDFORM. "set_order
*& Form set_fieldcat2
Adds an entry to the field catalog.
p_colpos: Column position.
p_fieldname: Field of internal table which is being described by
* this record of the field catalog.
p_ref_fieldname: (Optional) Table field / data element which
* describes the properties of the field.
* If this field is not given, it is copied from
* the fieldname.
p_ref_tabname: (Optional) Table which holds the field referenced
* by <<p_ref_fieldname>>.
If this is not given, the parameter
<<p_ref_fieldname>> references a data element.
p_outputlen: (Optional) Column width.
p_noout: (Optional) If set to 'X', states that the field is not
* showed initially. If so, the field has to be
included in the report at runtime using the display
options.
p_seltext_m: (Optional) Medium label to be used as column header.
p_seltext_l: (Optional) Long label to be used as column header.
p_seltext_s: (Optional) Small label to be used as column header.
p_reptext_ddic: (Optional) Extra small (heading) label to be
* used as column header.
p_ddictxt: (Optional) Set to 'L', 'M', 'S' or 'R' to select
whether to use SELTEXT_L, SELTEXT_M, SELTEXT_S,
or REPTEXT_DDIC as text for column header.
p_hotspot: (Optional) If set to 'X', this field will be used
* as a hotspot area for cursor, alolowing the user
* to click on the field.
p_showasicon: (Optional) If set to 'X', this field will be shown
as an icon and the contents of the field will set
* which icon to show.
p_checkbox: (Optional) If set to 'X', this field will be shown
as a checkbox.
p_edit: (Optional) If set to 'X', this field will be editable.
p_dosum: (Optional) If set to 'X', this field will be summed
(aggregation function) according to the grouping set
by the order functions.
t_fieldcat: Table which contains the whole fieldcat.
FORM set_fieldcat2 USING
p_colpos p_fieldname p_ref_fieldname p_ref_tabname
p_outputlen p_noout
p_seltext_m p_seltext_l p_seltext_s p_reptext_ddic p_ddictxt
p_hotspot p_showasicon p_checkbox p_edit
p_dosum
t_fieldcat TYPE slis_t_fieldcat_alv.
DATA: wa_fieldcat TYPE slis_fieldcat_alv.
CLEAR wa_fieldcat.
General settings
wa_fieldcat-fieldname = p_fieldname.
wa_fieldcat-col_pos = p_colpos.
wa_fieldcat-no_out = p_noout.
wa_fieldcat-hotspot = p_hotspot.
wa_fieldcat-checkbox = p_checkbox.
wa_fieldcat-icon = p_showasicon.
wa_fieldcat-do_sum = p_dosum.
Set reference fieldname, tablenam and rollname.
If p_ref_tabname is not given, the ref_fieldname given
is a data element.
If p_ref_tabname is given, the ref_fieldname given is a
field of a table.
In case ref_fieldname is not given,
it is copied from the fieldname.
IF p_ref_tabname IS INITIAL.
wa_fieldcat-rollname = p_ref_fieldname.
ELSE.
wa_fieldcat-ref_tabname = p_ref_tabname.
IF p_ref_fieldname EQ space.
wa_fieldcat-ref_fieldname = wa_fieldcat-fieldname.
ELSE.
wa_fieldcat-ref_fieldname = p_ref_fieldname.
ENDIF.
ENDIF.
Set output length.
IF NOT p_outputlen IS INITIAL.
wa_fieldcat-outputlen = p_outputlen.
ENDIF.
Set text headers.
IF NOT p_seltext_m IS INITIAL.
wa_fieldcat-seltext_m = p_seltext_m.
ENDIF.
IF NOT p_seltext_l IS INITIAL.
wa_fieldcat-seltext_l = p_seltext_l.
ENDIF.
IF NOT p_seltext_s IS INITIAL.
wa_fieldcat-seltext_s = p_seltext_s.
ENDIF.
IF NOT p_reptext_ddic IS INITIAL.
wa_fieldcat-reptext_ddic = p_reptext_ddic.
ENDIF.
IF NOT p_ddictxt IS INITIAL.
wa_fieldcat-ddictxt = p_ddictxt.
ENDIF.
Set as editable or not.
IF NOT p_edit IS INITIAL.
wa_fieldcat-input = 'X'.
wa_fieldcat-edit = 'X'.
ENDIF.
APPEND wa_fieldcat TO t_fieldcat.
ENDFORM. "set_fieldcat2
======================== Subroutines called by ALV ================
*& Form top_of_page
Called on top_of_page ALV event.
Prints the heading.
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
i_logo = <<If you want to set a logo, please,
uncomment and edit this line>>
it_list_commentary = t_heading.
endform. " alv_top_of_page
*& Form user_command
Called on user_command ALV event.
Executes custom commands.
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
Example Code
Executes a command considering the sy-ucomm.
CASE r_ucomm.
WHEN '&IC1'.
Set your "double click action" response here.
Example code: Create and display a status message.
DATA: w_msg TYPE string,
w_row(4) TYPE n.
w_row = rs_selfield-tabindex.
CONCATENATE 'You have clicked row' w_row
'field' rs_selfield-fieldname
'with value' rs_selfield-value
INTO w_msg SEPARATED BY space.
MESSAGE w_msg TYPE 'S'.
ENDCASE.
End of example code.
endform. "user_command -
How to filter standard ALV report with custom UI element?
Hello Expert,
I got a requirement to filter standard ALV report based on the custom UI element (which is created in the screen before displaying the ALV report). Upon entering the values in the Custom field, the ALV report is displayed accordingly.
Any ideas how to approach it?
Thanks,
MohammedHi,
Okay, let me explain the steps in detail
Let us say you have alv table with 10 records and alv table is shown first time with all 10 records
Create an internal table in component controller's attribute GT_ORIGINAL_DATA and save all 10 records into this table first time
Now, user enters value in FILTER_MATNR field 123 and press apply_filter button or press enter key
Read the value of field filter_matnr and get the only matching records from global internal table GT_ORIGINAL_DATA into local internal table as below
data lv_matnr type matnr.
data lt_data like wd_comp_controller->gt_original_data.
" read the value from context attribute of filter_matnr
lv_matnr = ???
" copy all data into local table
lt_data[] = wd_comp_controller->gt_original_data.
"delete the records which does not match
delete lt_data where matnr NP lv_matnr.
Now, bind the data lt_data to context node of alv table
Hope this helps you.
Regards,
Rama -
ALV Report Interesting requirment ?
Hello,
I have got a Peculiar requirment like i am have generated a ALV report based on my material number, for the each material number(Material) i am having a word document in my local desktop.
After displaying the list of material if i want to see the details of a particular material, my client want like if he double click on Material-1 then the document related to material-1 which is present on local machine has to open automatically.
Is this requirment can be possible.
The concept that i am having is like i have created a button in my application tool bar where when i click on that button i am able to open the Browser there by he can open the document that he want but, its like when he choose Material-1 in the list and click draw button the doument related to Materail-1 should automatically open.
The Code that i am having at present is like...
TABLES: ZAAA.
TYPE-POOLS:
SLIS.
DATA:
BEGIN OF T_AAA OCCURS 0,
CHECKBOX,
COLOR(3).
INCLUDE STRUCTURE ZAAA.
DATA: END OF T_AAA.
DATA:
T_TAAA LIKE STANDARD TABLE OF T_AAA .
DATA:
FS_AAA LIKE LINE OF T_TAAA.
DATA:
FS_LAYOUT TYPE SLIS_LAYOUT_ALV,
W_PROGRAM TYPE SY-REPID.
*DATA: fname TYPE localfile .
DATA: v_rc TYPE i.
data: v_file type string.
DATA: lt_filetab TYPE filetable.
DATA: ls_filetab LIKE LINE OF lt_filetab.
data: p_file TYPE localfile.
*AT SELECTION-SCREEN on VALUE-REQUEST FOR p_file.
SELECT *
FROM ZAAA
INTO CORRESPONDING FIELDS OF TABLE T_AAA.
FS_LAYOUT-INFO_FIELDNAME = 'COLOR'.
FS_LAYOUT-BOX_FIELDNAME = 'CHECKBOX'.
W_PROGRAM = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_PROGRAM
I_CALLBACK_PF_STATUS_SET = 'DRAWING'
I_CALLBACK_USER_COMMAND = 'AAA_INFO'
I_STRUCTURE_NAME = 'ZAAA'
IS_LAYOUT = FS_LAYOUT
TABLES
T_OUTTAB = T_AAA
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 ZAAA
text
-->RT_EXTAB text
FORM DRAWING USING RT_EXTAB TYPE SLIS_T_EXTAB..
SET PF-STATUS 'DRAWING' EXCLUDING RT_EXTAB.
ENDFORM. "FLIGHT
*& Form &----
text
-->UCOMM text
-->SELFIELD text
FORM AAA_INFO USING UCOMM LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
SELFIELD-REFRESH = 'X'.
CASE UCOMM.
WHEN 'DRAW'.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
FILE_NAME = fname
CALL METHOD cl_gui_frontend_services=>file_open_dialog
CHANGING
file_table = lt_filetab
rc = v_rc
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
READ TABLE lt_filetab INTO ls_filetab INDEX 1.
IF sy-subrc = 0.
v_file = ls_filetab-filename.
CALL METHOD cl_gui_frontend_services=>execute
EXPORTING
document = v_file.
ENDIF.
ENDCASE.
ENDFORM. "SPFLI_INFO
For security resons i changed the table name.
Please can anyone share there views on this requirement.
ThksFirst Keep all the material related documents in a folder
and name the documents with your material name.doc
In your ALV Function module REUSE_ALV_GRID
pass this parameter
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'.
In your abap program create a sub routine USER_COMMAND.
if u double click on ALV your sy-ucomm is &IC1.
so if u double click this user_command form will be called.
check whether they click on material.
FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM.
if ucomm = '&IC1' and selfield-fieldname = 'MATNR'.
CALL FUNCTION 'ITS_FILE_OPEN_DIALOG'
EXPORTING
WINDOW_TITLE = WINDOW_TITLE
DEFAULT_EXTENSION = DEFAULT_EXTENSION
DEFAULT_FILENAME = DEFAULT_FILENAME
FILE_FILTER = FILTER
WITH_ENCODING = WITH_ENCODING
INITIAL_DIRECTORY = INITIAL_DIRECTORY
MULTISELECTION = MULTISELECTION
CHANGING
FILE_TABLE = FILE_TABLE
RC = RC
EXCEPTIONS
OTHERS = 1.
endif.
for this function module pass initial directory as your folder.
default extension is your extension.
default file name is your material code available in selfield-fieldname.
automatically it will open -
Jump from alv report to qa03 screen based on PRUEFLOS field
Hi experts,
I developed one alv report ,in that one field name is PRUEFLOS (inspection lot number).I want to jump from alv report
to QA03 screen based on PRUEFLOS field.I wrote in this way but i didn't get.
FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM SELFIELD TYPE SLIS_SELFIELD.
CASE SELFIELD-FIELDNAME.
WHEN 'PRUEFLOS'.
READ TABLE T_FINAL INDEX SELFIELD-TABINDEX.
SET PARAMETER ID 'QLS' FIELD T_FINAL-PRUEFLOS.
CALL TRANSACTION 'QA03' AND SKIP FIRST SCREEN.
ENDCASE.
ENDFORM.
what is the problem ?pls help me in this.Hi Ram,
Recheck:
1) You have passed 'FORM USER_COMMAND' in 'I_CALLBACK_USER_COMMAND' while calling f.m. for ALV displa, and
2) You have checked the value of user command, i.e.
FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM SELFIELD TYPE SLIS_SELFIELD.
CASE SY-UCOMM.
WHEN '&IC1'.
CASE SELFIELD-FIELDNAME.
WHEN 'PRUEFLOS'.
READ TABLE T_FINAL INDEX SELFIELD-TABINDEX.
SET PARAMETER ID 'QLS' FIELD T_FINAL-PRUEFLOS.
CALL TRANSACTION 'QA03' AND SKIP FIRST SCREEN.
ENDCASE.
ENDCASE.
ENDFORM.
Regards,
Birendra -
Hi,
Can you plz help to get a report based on Depot plants.
I have transffered materials frm one main plant to 8 different Depot Plants.Can u plz help me to get reports that helps me to get the detailed list of stocks in depot plants and to know how much is transferred and other details happened while transferring.
Regards,
PrasanthHi
you can use MB51.
Give input of materials you have transfered & movement type & date of posting.
You will get the report.
Hope it helps you.
Regards
YMREDDY -
I want to see out put of data 'plant wise' as vertical left in ALV report
I want to see out put of data 'plant wise' as vertical left in ALV report.
Can anybody suggest me with coding.
thanks
nareshHiiii
Sorry ...however could u be rather specific ..what u want ... unable to under stand ur requirement ...
earlier also u asked some thing similiar query..i think that didnt solve ur issue ...
is that u want a tree structure report ??????or what type of o/p do u want to have .....le tthat be more explanatory ....
regards
chandu reddy -
Authorization based on plant and Purchase order document type
Hi
My client has a requirement wherein a user will have authorization for transactions only in his plant. But only for Purchase order document type UB (Stock Transport Order) the user should be allowed to create for all plants.
In short, if Purchase order document type is UB, should be allowed for all plants
if Purchase order document type is NB, should be allowed to only one particular plant.
My Basis person says that such a restriction is not possible.
Kindly suggest me on how to provide a solution to this.
Thank U.Hi,
This is possible.In this case you need to create two seperate roles.
1)Create purchase order for all plants (This can be used in long text)
2)Create purchase order for <plant no> plants.
For case 1:--
i)Populate field BSART of M_BEST_BSA with UB.
ii)Populate field WERKS of M_BEST_WRK with '*'. SAP reccomends to fill up organizational data through organizational level tab only.So while doing this step you need to put * from organizational level tab only.
For case 2:--
i)Populate field BSART of M_BEST_BSA with NB.
ii)Populate field WERKS of M_BEST_WRK with 'plant no'.
Dont worry about the objects i mentioned those are maintained through SU24 and will be automatically pulled once you insert ME21 transaction code.
Let me know if it helps.
Thanks,
Aveek
Maybe you are looking for
-
Reading attachments of DMS server
Hi Experts, I have a requirement where in which i have to read the content of DMS(CV03N) attachment and display it in the quality management view of material master based on material plant combination. I could able to add a subscreen to the QM view
-
SAP NetWeaver 7.02 Java Trial version
Dear all, where can i download the "SAP NetWeaver 7.02 Java Trial version "??? Thanks and best regards..
-
Audiobooks in the right menu!
I bought my first audiobook today in Itunes. The file shows up correctly in the Itunes library under Audiobooks. If my Ipod is connected, it even shows up correctly there, by clicking devices, ipod, audiobooks. However, on the Ipod itself, it shows u
-
When buying app error invalid address
When buying app error invalid address
-
Lost vert/horiz scroll feature-no synaptic icon in hardware. HELP!
After a recent "computer cleansing" we seem to have lost our ability to use touchpad vert/horiz scroll feature- in hardware, there is no synaptic icon on which to click to remedy the problem. We have a Compac Presario A931NR notebook PC. Is there so