ABAP Query Quantity totals wrongly - M.Type 101+, 102-
Hi Friends,
Could any one help me in this? I created an ABAP Query for the combination of T.codes MB51 & MB52. When I see the total qty for the item which has GR and Goods return document.........say first by 101 I rerceive 5 nos and using 122 returns 3 nos. Here Query shows total is 8nos instead of 2 nos.
The same way correnponding price also shows for 8nos instead 2 nos.
Kind Regards,
Sankar.K
Hi Sankar,
You can use MSEG-SHKZG field for +(plus)/-(minus) indicator where 'H' is -(minus) and 'S' is +(plus).
I hope this can answer your problem.
Regards
Gunawan
Similar Messages
-
Sumup the quantities of 'Materials' which contains movement types 101, 102
hi
Iam extracting 'Materials' ,'Material Movement Types'and its 'Quantities' from MSEG table.
I want Sum Up The Quantities of particular Materials based on Movment Types=101,102.
So how can i do this one in transfer rules . Please let me know
kumarHi Ravi,
May be you can write a routine in the update rules to sum up those two movement types for Quantity for particular materials. Not sure though.... -
ABAP Query SUB-TOTALS by Month
Hi,
I am making an ABAP Query and I am trying to create sub-totals per month.
EX. Quantity Date
1 01/01/2008
2 01/02/2008
sub-total 3
1 02/01/2008
sub-total 1
does anyone know how i can do this? (create sub-totals based on the date field)
Thanks!I dont think standard ALV subtotalling will do like this. But there is one workaround
I would suggest you to have one more column named Month. In that column save the month for that row. Then do the subtotalling based on that field Month instead of date field.
Hope this will help
cheers
Kothand -
BEx abap query analyzer with wrong port in url adress
Hi
Starting TA RSRT you can open ABAP WEB query in separatly browser
window.
For that an url adress is generated.
Normaly it looks like <server>:8000/xxx.
One my workstation it works well & fine. In the other hand some of our
coleagues get url with a port 8100, what wrong is.
Could you explain this?
Many thanks for a feedback.
Bestr Regards
FrancoHi Franco,
Strange... This should works or not for everybody.
Maybe you have a web dispatcher.Sometimes this is the root cause.
Well, first of all, check the note below:
>> 805344 - How URLs are generated automatically in BW
Ensure your system is correctly configured by this note.
Best Regards,
Edward John -
ABAP Query : code to change the display
Hi all,
I have created an Abap Query and generated it. I see the output now as follows:
<u>Bill.doc</u> <u>Item</u> <u>Net value</u> <u>Total amt</u>
900000 10 100 600
900000 20 200 600
900000 30 300 600
900001 10 250 250
900002 10 300 500
900002 20 200 500
Now I want the total amt to be displayed only once for each billing document only for the first item and for the other line items it should be blank as shown below.
<u>Bill.doc</u> <u>Item</u> <u>Net value</u> <u>Total amt</u>
900000 10 100 600
900000 20 200
900000 30 300
900001 10 250 250
900002 10 300 500
900002 20 200
Can someone please explain me where and how I should write the code to get this working?
Thanks,
N
Helpful answers will be awarded for sure.Hi Manohar,
I am getting the total amount from a field which exists in one of the tables which i used in the abap query.
the total amount is appearing correctly...i dont need to modify that. i just need to display it only once for each billing doc for the first item.
i want to know where i should do the coding...i mean in the Infoset or the Abap Program that gets created when i generate the infoset.
Thanks!
N
Message was edited by:
Narmada Mallavaram
null -
Account assignment for Movt type 101 and 501
All SAP Gurus,
We want to do the account assignment for movt types 101, 102, 122, 123, 201, 202, 261, 262 accourding to the movement types.
We are aware that the Transaction Key is 'GBB'.
But how to know that which 'General Modification' is used for which movement types.
(in short where we can find this link between movement types and Transaction Key and 'General Modification')
Regards,To know this first you have to know what does the different general modifications means for GBB:
AUA: for order settlement
AUF: for goods receipts for orders (without account assignment)
and for order settlement if AUA is not maintained
AUI: Subsequent adjustment of actual price from cost center directly
to material (with account assignment)
BSA: for initial entry of stock balances
INV: for expenditure/income from inventory differences
VAX: for goods issues for sales orders without
account assignment object (the account is not a cost element)
VAY: for goods issues for sales orders with
account assignment object (account is a cost element)
VBO: for consumption from stock of material provided to vendor
VBR: for internal goods issues (for example, for cost center)
VKA: for sales order account assignment
(for example, for individual purchase order)
VKP: for project account assignment (for example, for individual PO)
VNG: for scrapping/destruction
VQP: for sample withdrawals without account assignment
VQY: for sample withdrawals with account assignment
ZOB: for goods receipts without purchase orders (mvt type 501)
ZOF: for goods receipts without production orders
(mvt types 521 and 531)
You can also define your own account groupings. If you intend to post goods issues for cost centers (mvt type 201) and goods issues for orders (mvt type 261) to separate consumption accounts, you can assign the account grouping ZZZ to movement type 201 and account grouping YYY to movement type 261
Then go and check OMWN.
Regards,
Indranil -
Hello friends,
can somebody tell me what are the steps involved in MIGO for movement types 101 & 102. what is the actual procedure in MIGO, what I have to do in MIGO for movement types 101 and 102?
can someboday explain me in detail?
my client requirement is goods receipt from plant to depot or from depot to plant.
regards,
Sekhar_SD consultant.MIGO -> A01 Good receipt -> Purchase order ->
Enter the purchase order number ->
Ensure that the movement type is 101 -> SAVE -> we will get
a material document number corresponding to the movement
movement type 102 is for reversing the 101. -
Wrong sequence in selection screen generated by ABAP Query
Hi,
I am developing a query to display the data in the view.
My query has 8 selection fields totally.
As part of my requirement I have added selection parameter in the
selections tab of the infoset and maintained the sequence as 9.
Inspite of maintaining the sequence number as 9 in the infoset, It is
appearing first in the selection screen of the query.
I tried putting different numbers in the sequence number, but even it
is appearing first in the selection screen.
Can you please let me know how to display the selections declared in
the infoset as per the sequence required.
Thanks,
Madhuri.Actually what happen when you declare your own fields in ABAP query . you have to care about the sequence . As an example if youre selecting lets say state name , you have two variables
<b>1-state
2- land</b>
for state you have to select land first , if your state is first and land is 2nd it gave you the error of sequence .
Because you have to get data in land first in order to get state specific to the land .
it should be
1-Land
2-State
Just see the your fields , Im sure youre missing that .
<b>You can also see the NO ( field ) in Query ( Sq03 ) . where you can define the seqence on selection.</b>
hope thisll help you .
Pl...Award the points .
Thanks
Saquib<b></b>
Message was edited by: Saquib Khan -
Hide/Delete lines from ABAP Query output when Quantity is 0
Hi all,
I'm changing an existing abap query. My requirement is to delete the rows from the report output where qantity = 0.
I tried the following ways.
1. In SQ01, select the quantity field and check the checkbox for "Display only field <> 0", but this didnt worked as it will
supress the zero from display.
2. I tried to write code in the Infoset SQ02->Edit->Code. I wrote the following code "CHECK vbep-wmeng IS NOT INITIAL".
Here the problem is, the code is not executing in the test client. When I open the Infoset in test(i mean development test)
client the code is there, but when i execute the program its not working. I tried using "BREAK-POINT", program executions
does not stop at the break point. There is existing code in the event "START-OF-SELECTION", this code I'm able to see in the
query program opened through SE38. I edited the existing code and kept a break point in between, and now checked in the
program in SE38, but the changes are not reflected. I'm able to see old code only(even after save n generate).
3. Gave search in SCN, google etc.
Please note.
1. I'm not using any Logical Database in the Infoset. Its a simple join of 4 tables.
2. Query is created in the Global Area (cross client) not client specific.
Can anybody tell me what could be the problem and how can Over the above issues and achive the requirement.
Thanks in advance.
Edited by: Mr A on Feb 25, 2010 1:39 AMDear Mr A,
Can i know how did u solve the issue even i'm facing the same problem.
Regards,
Karan Bhasin -
Can we join two totals tables in ABAP Query
Hey Gurus!
Can we join two totals tables in ABAP query.
I am tyring to join FAGFLEXT with internal orders totals table.
Thanks
SHi,
Report painter majorily operates around characteristics and key figures.
ABAP query comes even more handy. The advantage is -
1. You can link many tables
2. Create selection screen as you like to have
3. User friendly report creation
4. Logic can also be coded.
5. Authorization can be set
I have written a article in SDN, which gives you an idea as to how to go about using ABAP query. Have a look on this - [Article - Practical Usage of ABAP Query|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/20f6b256-23be-2b10-8b93-cad83a617634]
Regards,
Sridevi -
GR output quantity for different material types using 101 mvt
Hi All
Is it possible to have separate GR slip quantities for the same movement type (101) but for different stock types.
I would like 3 GR slips for mvt type 101 for directly procured materials AND
I would like 1 GR slip for mvt type 101 for stock materials
Therefore, the material type on goods receipt would decide how many GR slips would be printed.
What config is necessary?
Thanks in advance
Darrenmaterial type is fixed for a material, it is not changed for GR.
you can make no of GRs or one po.
for stock items you need to make one PO and matrial for account assignment need separete PO.
account assignment PO > material direclty goes to cost center and consumption accouont
no configuration required. -
How to add join conditions in ABAP Query.
Hi,
I need a help on "ABAP Query".
How to add join conditions in ABAP Query.
Thanks in advance.
Thanks & Regards,
RamanaHi,
See below code,
*& Report ZRNP_ALV_SO
REPORT zrnp_alv_so MESSAGE-ID z7rnp .
INCLUDE zrnp_include .
*SELECTION SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-004 .
SELECT-OPTIONS: s_vbeln FOR vbak-vbeln ,
s_auart FOR v_auart ,
s_vkorg FOR v_vkorg ,
s_spart FOR v_spart ,
s_kunnr FOR v_kunnr ,
s_matnr FOR v_matnr .
SELECTION-SCREEN END OF BLOCK blk1 .
*AT SELECTION SCREEN *
AT SELECTION-SCREEN.
SELECT SINGLE vbeln
FROM vbak INTO vbak-vbeln
WHERE vbeln IN s_vbeln.
IF sy-subrc <> 0.
MESSAGE e202.
ENDIF.
*START OF SELECTION *
START-OF-SELECTION .
PERFORM data_select.
PERFORM t_sort USING i_sort .
PERFORM event_cat USING i_event .
PERFORM fld_cat USING i_fldcat[] .
PERFORM t_layout USING i_layout .
PERFORM fld_cat2 USING i_fldcat2[] .
PERFORM call_alv.
* DATA SELECT *
*& Form DATA_SELECT
* text
* --> p1 text
* <-- p2 text
FORM data_select .
REFRESH: it_vbfa, it_so1, it_del_ful ,it_del1 .
BREAK-POINT.
*SELECT*
*a~vbeln*
*a~auart*
*a~vkorg*
*a~spart*
*a~kunnr*
*b~posnr*
*b~matnr*
*c~maktx*
*b~kwmeng*
*b~vrkme*
*INTO TABLE it_so1 FROM vbak AS a*
*INNER JOIN vbap AS b ON b~vbeln = a~vbeln*
*INNER JOIN makt AS c ON c~matnr = b~matnr*
*AND c~spras = sy-langu*
*WHERE a~vbeln IN s_vbeln .*
IF sy-subrc = 0.
SORT it_so1 BY vbeln.
DELETE ADJACENT DUPLICATES FROM it_so1.
ENDIF.
* COLURING DISPLAY *
DATA: ld_color(1) TYPE c .
* LOOP AT it_so1 INTO wa_so.
* Populate color variable with colour properties
* Char 1 = C (This is a color property)
* Char 2 = 3 (Color codes: 1 - 7)
* Char 3 = Intensified on/off ( 1 or 0 )
* Char 4 = Inverse display on/off ( 1 or 0 )
* i.e. wa_ekko-line_color = 'C410'
* ld_color = ld_color + 1.
* Only 7 colours so need to reset color value
* IF ld_color = 8.
* ld_color = 1.
* ENDIF.
* CONCATENATE 'C' ld_color '10' INTO wa_so-line_color.
** wa_ekko-line_color = 'C410'.
* MODIFY it_so1 FROM wa_so.
* ENDLOOP .
* IF sy-subrc = 0.
IF NOT it_so1[] IS INITIAL.
SELECT vbelv
posnv
vbeln
posnn
vbtyp_n
INTO TABLE it_vbfa
FROM vbfa
FOR ALL ENTRIES IN it_so1
WHERE vbelv = it_so1-vbeln
AND posnn = it_so1-posnr
AND vbtyp_n ='J' .
IF sy-subrc = 0.
SELECT vbeln
posnr
matnr
werks
lgort
charg
lfimg
vrkme
FROM lips INTO TABLE it_del_ful
FOR ALL ENTRIES IN it_vbfa
WHERE vbeln = it_vbfa-vbeln
AND posnr = it_vbfa-posnn.
ENDIF.
ENDIF.
ENDFORM. " DATA_SELECT
**************** EVENT CATALOG ****************************************
*& Form EVENT_CAT
* text
* -->P_I_EVENT text
FORM event_cat USING p_i_event TYPE slis_t_event .
REFRESH p_i_event .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
* EXPORTING
* I_LIST_TYPE = 0
IMPORTING
et_events = p_i_event
* EXCEPTIONS
* LIST_TYPE_WRONG = 1
* OTHERS = 2
* IF sy-subrc <> 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* ENDIF.
READ TABLE p_i_event WITH KEY name = slis_ev_top_of_page INTO t_event.
IF sy-subrc = 0.
MOVE 'TOP_OF_PAGE' TO t_event-form.
MODIFY p_i_event FROM t_event INDEX sy-tabix TRANSPORTING form.
ENDIF.
CLEAR t_event .
ENDFORM. " EVENT_CAT
**********FORM FOR EVENT TOP_OF_PAGE**********************************
FORM top_of_page .
REFRESH i_listheader.
DATA: t_header TYPE slis_listheader.
DATA: v_text(50).
WRITE sy-datum TO v_text.
CLEAR t_header.
t_header-typ = 'S'.
t_header-key = "Date".
t_header-info = v_text.
APPEND t_header TO i_listheader.
CLEAR t_header.
CLEAR v_text.
WRITE: 'SALES ORDER & DELIVERY DETAILS REPORT ' TO v_text .
t_header-typ = 'S'.
t_header-key = 'TITLE'.
t_header-info = v_text.
APPEND t_header TO i_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = i_listheader.
* I_LOGO = 'ALV_BACKGROUND'.
* I_END_OF_LIST_GRID =
ENDFORM. "TOP_OF_PAGE
******** FIRST ALV GRID DISPLAY ***************************************
FORM call_alv .
* FORM TO MAKE THE CELL CONTENTS INVISIBLE.
* PERFORM INVISIBLE_CELL_CONTENTS. *
*EXCLUDE-DECLARATION.
CLEAR wa_exclude.
wa_exclude-fcode = '&VEXCEL'.
APPEND wa_exclude TO i_exclude.
*& Form CALL_ALV
* text
* --> p1 text
* <-- p2 text
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
* I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND1'
i_callback_top_of_page = 'TOP_OF_PAGE'
i_background_id = 'ALV_BACKGROUND'
is_layout = i_layout
it_fieldcat = i_fldcat[]
it_excluding = i_exclude
it_sort = i_sort
it_events = i_event
TABLES
t_outtab = it_so1
* 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. " CALL_ALV
************** FIRST FIELDCATALOG *************************************
*& Form FLD_CAT
* text
* -->P_I_FLDCAT[] text
FORM fld_cat USING p_i_fldcat TYPE slis_t_fieldcat_alv.
CLEAR i_fldcat.
i_fldcat-fieldname = 'VBELN'. "FIELD FOR WHICH CATALOG ID FILLED
i_fldcat-tabname = 'IT_SO1'."TABLE NAME
i_fldcat-seltext_m = 'SALES ORDER NO.'.
i_fldcat-col_pos = 1. " POSITION OF THE COLUMN.
i_fldcat-outputlen = 20. " SET THE OUTPUT LENGTH.
i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.
i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT
"SCROLLABLE AND HIDDABLE.
i_fldcat-hotspot = 'X'.
i_fldcat-just(1) = 'C'.
APPEND i_fldcat.
CLEAR i_fldcat.
i_fldcat-fieldname = 'AUART'. "FIELD FOR WHICH CATALOG ID FILLED
i_fldcat-tabname = 'IT_SO1'."TABLE NAME
i_fldcat-seltext_m = 'SALES DOC. TYPE'.
i_fldcat-col_pos = 2. " POSITION OF THE COLUMN.
i_fldcat-outputlen = 15. " SET THE OUTPUT LENGTH.
i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.
i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT
"SCROLLABLE AND HIDDABLE.
i_fldcat-just(1) = 'C'.
APPEND i_fldcat.
CLEAR i_fldcat.
i_fldcat-fieldname = 'VKORG'. "FIELD FOR WHICH CATALOG ID FILLED
i_fldcat-tabname = 'IT_SO1'.
i_fldcat-seltext_m = 'SALES ORG.'.
i_fldcat-col_pos = 3. " POSITION OF THE COLUMN.
i_fldcat-outputlen = 12. " SET THE OUTPUT LENGTH.
i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.
i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT
"SCROLLABLE AND HIDDABLE.
i_fldcat-just(1) = 'C'.
APPEND i_fldcat.
CLEAR i_fldcat.
i_fldcat-fieldname = 'SPART'. "FIELD FOR WHICH CATALOG ID FILLED
i_fldcat-tabname = 'IT_SO1'.
i_fldcat-seltext_m = 'DIVISION'.
i_fldcat-col_pos = 4. " POSITION OF THE COLUMN.
i_fldcat-outputlen = 10. " SET THE OUTPUT LENGTH.
i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.
i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT
"SCROLLABLE AND HIDDABLE.
i_fldcat-just(1) = 'C'.
APPEND i_fldcat.
CLEAR i_fldcat.
i_fldcat-fieldname = 'KUNNR'. "FIELD FOR WHICH CATALOG ID FILLED
i_fldcat-tabname = 'IT_SO1'.
i_fldcat-seltext_m = 'SOLD TO PARTY'.
i_fldcat-col_pos = 5. " POSITION OF THE COLUMN.
i_fldcat-outputlen = 15. " SET THE OUTPUT LENGTH.
i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.
i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT
"SCROLLABLE AND HIDDABLE.
i_fldcat-just(1) = 'C'.
APPEND i_fldcat.
CLEAR i_fldcat.
i_fldcat-fieldname = 'POSNR'. "FIELD FOR WHICH CATALOG ID FILLED
i_fldcat-tabname = 'IT_SO1'.
i_fldcat-seltext_m = 'SALES DOC. ITEM'.
i_fldcat-col_pos = 6. " POSITION OF THE COLUMN.
i_fldcat-outputlen = 17. " SET THE OUTPUT LENGTH.
i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.
i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT
"SCROLLABLE AND HIDDABLE.
i_fldcat-just(1) = 'C'.
APPEND i_fldcat.
CLEAR i_fldcat.
i_fldcat-fieldname = 'MATNR'. "FIELD FOR WHICH CATALOG ID FILLED
i_fldcat-tabname = 'IT_SO1'.
i_fldcat-seltext_m = 'MATERIAL NO.'.
i_fldcat-col_pos = 7. " POSITION OF THE COLUMN.
i_fldcat-outputlen = 20. " SET THE OUTPUT LENGTH.
i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.
i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT
"SCROLLABLE AND HIDDABLE.
i_fldcat-just(1) = 'C'.
APPEND i_fldcat.
CLEAR i_fldcat.
i_fldcat-fieldname = 'MAKTX'. "FIELD FOR WHICH CATALOG ID FILLED
i_fldcat-tabname = 'IT_SO1'.
i_fldcat-seltext_m = 'DESCRIPTION'.
i_fldcat-col_pos = 8. " POSITION OF THE COLUMN.
i_fldcat-outputlen = 20. " SET THE OUTPUT LENGTH.
i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.
i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT
"SCROLLABLE AND HIDDABLE.
i_fldcat-just(1) = 'C'.
APPEND i_fldcat.
CLEAR i_fldcat.
i_fldcat-fieldname = 'KWMENG'. "FIELD FOR WHICH CATALOG ID FILLED
i_fldcat-tabname = 'IT_SO1'.
i_fldcat-seltext_m = 'QUANTITY'.
i_fldcat-col_pos = 9. " POSITION OF THE COLUMN.
i_fldcat-outputlen = 15. " SET THE OUTPUT LENGTH.
i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.
i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT
"SCROLLABLE AND HIDDABLE.
i_fldcat-do_sum = 'X'. " For doing "SUM"
i_fldcat-just(1) = 'C'.
APPEND i_fldcat.
CLEAR i_fldcat.
i_fldcat-fieldname = 'VRKME'. "FIELD FOR WHICH CATALOG ID FILLED
i_fldcat-tabname = 'IT_SO1'.
i_fldcat-seltext_m = 'SALES UNIT'.
i_fldcat-col_pos = 10. " POSITION OF THE COLUMN.
i_fldcat-outputlen = 10. " SET THE OUTPUT LENGTH.
i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.
i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT
"SCROLLABLE AND HIDDABLE.
i_fldcat-just(1) = 'C'.
APPEND i_fldcat.
ENDFORM. " FLD_CAT
****************** ALV SORTING ***************************************
*& Form SORT
* text
* -->P_I_SORT text
FORM t_sort USING p_i_sort TYPE slis_t_sortinfo_alv .
DATA: i_sort TYPE slis_sortinfo_alv .
REFRESH p_i_sort .
CLEAR i_sort.
i_sort-spos = 1.
i_sort-tabname = 'IT_SO1'.
i_sort-fieldname = 'VBELN'.
i_sort-up = 'X'.
i_sort-subtot = 'X'.
i_sort-group = '*'.
APPEND i_sort TO p_i_sort.
ENDFORM. " SORT
*FORM SET_PF_STATUS USING rt_extab TYPE slis_t_extab.
* SET PF-STATUS 'ZSTANDARD'.
*ENDFORM. "Set_pf_status
***********FORM FOR EVENT USER_COMMAND1********************************
FORM user_command1 USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
*CASE R_UCOMM .
* WHEN '&IC1' .
* IF rs_selfield-FIELDNAME = 'VBELN' .
* ENDIF .
* WHEN OTHERS .
* ENDCASE .
CLEAR wa_so.
REFRESH: it_del1 .
IF r_ucomm = '&IC1' AND rs_selfield-fieldname = 'VBELN' AND
rs_selfield-value IS NOT INITIAL.
READ TABLE it_so1 INTO wa_so INDEX rs_selfield-tabindex.
IF sy-subrc = 0.
LOOP AT it_vbfa INTO wa_vbfa WHERE vbelv = wa_so-vbeln
AND posnv = wa_so-posnr.
READ TABLE it_del_ful INTO wa_it_del_ful
WITH KEY vbeln = wa_vbfa-vbelv
posnr = wa_vbfa-posnn.
IF sy-subrc = 0.
CLEAR wa_del.
MOVE wa_it_del_ful TO wa_del.
APPEND wa_del TO it_del1.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
********* SECOND ALV GRID DISPLAY ***********************************
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
* I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND2'
i_callback_top_of_page = 'TOP_OF_PAGE'
i_background_id = 'ALV_BACKGROUND'
it_fieldcat = i_fldcat2[]
it_sort = i_sort
TABLES
t_outtab = it_del_ful
* 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 . "USER_COMMAND1
********** FORM FOR EVENT USER_COMMAND 2 ******************************
FORM user_command2 USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CLEAR wa_so.
REFRESH: it_del1 .
IF r_ucomm = '&IC1' AND rs_selfield-fieldname = 'VBELN' AND
rs_selfield-value IS NOT INITIAL.
READ TABLE it_so1 INTO wa_so INDEX rs_selfield-tabindex.
* IF SY-SUBRC = 0.
* LOOP AT it_vbfa INTO wa_vbfa WHERE vbelv = WA_SO-vbeln
* AND posnv = WA_SO-posnr.
READ TABLE it_del_ful INTO wa_it_del_ful
WITH KEY vbeln = rs_selfield-value
" vbeln = wa_vbfa-vbeln
posnr = wa_vbfa-posnn.
IF rs_selfield-fieldname = 'VBELN'.
SET PARAMETER ID 'VL' FIELD wa_vbfa-vbeln .
CALL TRANSACTION 'VL03' AND SKIP FIRST SCREEN.
ENDIF .
* ENDLOOP.
* ENDIF.
ENDIF.
ENDFORM . "USER_COMMAND2
********* SECOND FIELDCATALOG ******************************************
*& Form FLD_CAT2
* text
* -->P_I_FLDCAT2[] text
FORM fld_cat2 USING p_i_fldcat2 TYPE slis_t_fieldcat_alv .
CLEAR i_fldcat2.
i_fldcat2-fieldname = 'VBELN'. "FIELD FOR WHICH CATALOG ID FILLED
i_fldcat2-tabname = 'IT_DEL_FUL'."TABLE NAME
i_fldcat2-seltext_m = 'DELIVERY NO.'.
i_fldcat2-col_pos = 1. " POSITION OF THE COLUMN.
i_fldcat2-outputlen = 20. " SET THE OUTPUT LENGTH.
i_fldcat2-emphasize = 'X'. " COLOR OF THIS COLUMN.
i_fldcat2-key = 'X'. " SO THAT THIS FIELD IS NOT
"SCROLLABLE AND HIDDABLE.
i_fldcat2-hotspot = 'X'.
i_fldcat2-just(1) = 'C'.
APPEND i_fldcat2.
CLEAR i_fldcat2.
i_fldcat2-fieldname = 'POSNR'. "FIELD FOR WHICH CATALOG ID FILLED
i_fldcat2-seltext_m = 'DELIVERY ITEM'.
i_fldcat2-col_pos = 2. " POSITION OF THE COLUMN.
i_fldcat2-outputlen = 20. " SET THE OUTPUT LENGTH.
i_fldcat2-emphasize = 'X'. " COLOR OF THIS COLUMN.
i_fldcat2-key = 'X'. " SO THAT THIS FIELD IS NOT
"SCROLLABLE AND HIDDABLE.
i_fldcat2-just(1) = 'C'.
APPEND i_fldcat2.
CLEAR i_fldcat2.
i_fldcat2-fieldname = 'MATNR'. "FIELD FOR WHICH CATALOG ID FILLED
i_fldcat2-seltext_m = 'MATERIAL NO.'.
i_fldcat2-col_pos = 3. " POSITION OF THE COLUMN.
i_fldcat2-outputlen = 20. " SET THE OUTPUT LENGTH.
i_fldcat2-emphasize = 'X'. " COLOR OF THIS COLUMN.
i_fldcat2-key = 'X'. " SO THAT THIS FIELD IS NOT
"SCROLLABLE AND HIDDABLE.
i_fldcat2-just(1) = 'C'.
APPEND i_fldcat2.
CLEAR i_fldcat2.
i_fldcat2-fieldname = 'WERKS'. "FIELD FOR WHICH CATALOG ID FILLED
i_fldcat2-seltext_m = 'PLANT.'.
i_fldcat2-col_pos = 4. " POSITION OF THE COLUMN.
i_fldcat2-outputlen = 20. " SET THE OUTPUT LENGTH.
i_fldcat2-emphasize = 'X'. " COLOR OF THIS COLUMN.
i_fldcat2-key = 'X'. " SO THAT THIS FIELD IS NOT
"SCROLLABLE AND HIDDABLE.
i_fldcat2-just(1) = 'C'.
APPEND i_fldcat2.
CLEAR i_fldcat2.
i_fldcat2-fieldname = 'LGORT'. "FIELD FOR WHICH CATALOG ID FILLED
i_fldcat2-seltext_m = 'ST. LOCATION'.
i_fldcat2-col_pos = 5. " POSITION OF THE COLUMN.
i_fldcat2-outputlen = 20. " SET THE OUTPUT LENGTH.
i_fldcat2-emphasize = 'X'. " COLOR OF THIS COLUMN.
i_fldcat2-key = 'X'. " SO THAT THIS FIELD IS NOT
"SCROLLABLE AND HIDDABLE.
i_fldcat2-just(1) = 'C'.
APPEND i_fldcat2.
CLEAR i_fldcat2.
i_fldcat2-fieldname = 'CHARG'. "FIELD FOR WHICH CATALOG ID FILLED
i_fldcat2-seltext_m = 'BATCH NO.'.
i_fldcat2-col_pos = 6. " POSITION OF THE COLUMN.
i_fldcat2-outputlen = 20. " SET THE OUTPUT LENGTH.
i_fldcat2-emphasize = 'X'. " COLOR OF THIS COLUMN.
i_fldcat2-key = 'X'. " SO THAT THIS FIELD IS NOT
"SCROLLABLE AND HIDDABLE.
i_fldcat2-just(1) = 'C'.
APPEND i_fldcat2.
CLEAR i_fldcat2.
i_fldcat2-fieldname = 'LFIMG'. "FIELD FOR WHICH CATALOG ID FILLED
i_fldcat2-seltext_m = 'ACT. DEL. QTY.'.
i_fldcat2-col_pos = 7. " POSITION OF THE COLUMN.
i_fldcat2-outputlen = 20. " SET THE OUTPUT LENGTH.
i_fldcat2-emphasize = 'X'. " COLOR OF THIS COLUMN.
i_fldcat2-key = 'X'. " SO THAT THIS FIELD IS NOT
"SCROLLABLE AND HIDDABLE.
i_fldcat2-just(1) = 'C'.
APPEND i_fldcat2.
CLEAR i_fldcat2.
i_fldcat2-fieldname = 'VRKME'. "FIELD FOR WHICH CATALOG ID FILLED
i_fldcat2-seltext_m = 'SALES UNIT.'.
i_fldcat2-col_pos = 8. " POSITION OF THE COLUMN.
i_fldcat2-outputlen = 20. " SET THE OUTPUT LENGTH.
i_fldcat2-emphasize = 'X'. " COLOR OF THIS COLUMN.
i_fldcat2-key = 'X'. " SO THAT THIS FIELD IS NOT
"SCROLLABLE AND HIDDABLE.
i_fldcat2-just(1) = 'C'.
APPEND i_fldcat2.
ENDFORM. " FLD_CAT2
***************** ALV LAYOUT *******************************************
*& Form LAYOUT
* text
* -->P_I_LAYOUT text
FORM t_layout USING p_i_layout TYPE slis_layout_alv .
p_i_layout-zebra = 'X'.
p_i_layout-totals_text = 'GRAND TOTAL ='.
* p_i_layout-CONFIRMATION_PROMPT = 'X'.
* p_i_layout-DEF_STATUS = ' '.
p_i_layout-info_fieldname = 'LINE_COLOR'.
ENDFORM. " LAYOUT -
Hi Friends,
can i send me Creation of ABAP QUERY...
REGARDS,What Is SAP Queries
Many times a need arises for SAP Users and Functional Consultants to generate quick reports without getting any ABAP coding done time taken to complete the coding in development, transport and test it in QA system and then transport to production is sometimes too long. In such cases, ABAP/4 query is a tool provided by SAP for generating these kind of reports.
Type of Report Desired:
Before starting to write an ABAP query, its advisable to decide the type of report that the user wants. ABAP query provides the following type of reports:
Basic List Simple report
Statistics Report containing statistical functions like Average &Percentage
Ranked List Report written for analytical purpose
The output is always seen in the order of Basic List, then Statistics and then Ranked List if any. One ABAP query can have one basic list, maximum of 9 statistics and maximum of 9 ranked lists.
In a nutshell, an ABAP/4 query can be designed in four steps
- Creation of a user group
- Creation of functional area
- Assignment of user group to functional area
- Creation of the query based on functional area
The various objects that form an ABAP query can be created in the following 2 ways:
- Tools => ABAP/4 Workbench => Utilities => ABAP/4 Query
OR
- By executing the transaction codes mentioned below:
SQ01 ABAP/4 Query
SQ02 Functional Area
SQ03 User group
Step I - Create Functional Area
In the functional area section, the user indicates from which part of the SAP database the data is going to be retrieved and how the data is to be retrieved by the query. One functional area can be assigned to many user groups. A functional area can be created with or without a logical database. To create a functional area with a logical database, one has to mention the name of the database and then select the fields from the tables that form the logical database.
ABAP Query Authorizations: To use an ABAP query, the user must have appropriate authorizations. Two ways of providing authorizations to the users are as follows:
- User groups
The user should be a part of at least one user group to run the corresponding ABAP query. This automatically restricts the access of the user to specific functional areas, and thus the corresponding underlying logical databases.
- Authorizations
The authorization object S_QUERY should be used to give proper authorizations to the user for a query. This authorization object has a field named ACTVT which can take values 02 for Change, 23 for Maintain and 67 for Translate.
This value determines whether the user can create and modify the query. The possible authorizations in the object are as follows:
S_QUERY_ALL Change, maintain and translate query
S_QUERY_UPD Change and Translate
Though the general concept of an ABAP query is moderately difficult, the results and the long term use of the ABAP query is worth the effort.
Creating the ABAP Query
To create the query use the menu path Environment => Queries
· Give a name to the query and click on the Create button
· Give the description of the query in the next screen. Specify the output length and select the processing option from the Further Processing Options box. The data can be displayed in various formats such as table, download to a file, and display in Word etc.
· Click on the Next screen icon. Select the functional group screen. All the functional groups created in the functional area are displayed. Select the groups that you desire fields from only these groups will be displayed in the output. Click on the respective check boxes and click on the Next Screen icon.
· The Select Field screen gets displayed. Select all the fields from the user group that you need to display on the output of the query. If required, specify the short names for the fields using the menu path Edit => Short Names => Switch On/Off or you can also change the selection text contains in the order you want to appear on the selection screen. You can also maintain column headers for the fields by using the menu path Edit => Column Header => Maintain.
· Click on the Next Screen icon to get the Selections Screen. Here you can check against the fields that you require to be shown on the selection screen.
· Now we need to specify the output type for the query as Basic List, Statistics or Ranked List. Choose the option Basic List.
· On the Basic List line structure screen the following things can be done
o Specify the report layout in detail lines on which the fields will appear.
o Order in which the fields will appear in the output
o Sort order for the fields this is optional.
o For the numeric fields you can check against the fields for which you require totals in the output.
o Beautify the output according to the options provided.
· Click on the next screen icon, to specify the control levels as mentioned below
o Specify the sort order. The default sort order is ascending and can be changed to descending if required.
o Totals for each field selected for sorting can be displayed
o To display the output of a field in a box click on the check box against box. To display a line after the output of a field, click on the check box against BlnkLn
o To display the output of a field on a new page click on the check box against New Page
· Click on the next screen icon to get the List Line options Screen. Here you can specify the background color for displaying the output.
· Click on the next screen icon to get the Field Output Option screen. In this you can specify the following:
o Change the output length or the display positions of the fields
o Specify the display position of the unit for quantity or currency fields. Click left radio button to display it before the figure, middle radio button to display it after the figure while last radio button to hide the unit altogether.
o Specify color for the column of every field under the Format option.
o Specify the label against the output of sort fields.
· Click on the Next screen option to go to the Basic List Header screen. Here you can specify
o Give page header and page footer for the output
o Include user name and date by specifying &N and &D respectively.
After providing all the above options you can save the query and execute it by clicking the Execute button twice
Regards,
Maha -
Performance of ABAP query program
Hi All,
A custom program AQNWZ_TALAT=====TCS_AP_ITEMS== is taking lot of time running. And when checked the cost of the select statement is very high.
I guessed it must be some custom abap query. Correct me if I am wrong.
Also please let me know how to do the performance tuning on this code? Should I be editing the program directly or should I edit at the abap query level.
Regards,
Pooja
Moderator message: Please Read before Posting in the Performance and Tuning Forum
Edited by: Thomas Zloch on Dec 3, 2010 11:01 AM>A few tips you can use for finetuning a Report
The actually a good collection of the most important pain points. But the recommendations are unfortunately quite poor, and even wrong. I have updated them a little bit.
And for German speaking people I have added a reference to a textbook, where arll my recommendations are explained in detail.
Siegfried
1) Use mostly primary key to access data.
... nonsense, the task determines the WHERE clause, it is not your choice
2) Before READ u sort the itab
No
3) use mostly the indexes fields in ur where clause.
... as 1, it is the other way, the task determines the WHERE-clause, make surwe that there is an index which
supports it
4) Restrict the the fields retrieved by your select sentences to the minimal set. (Avoid select *)
nonsense, most SELECT use and must use *, use field list in wide tables
5) try to use specify where clause so the abap sql optimizer chooses the right index.
o.k., but who understands that in depth?
6) Avoid sentences like select lifnr name1 into corresponding fields of lfa1 from lfa1 where....
feel free to use if required
(You should declare a working area and select into the working area, is twice faster)
... such general statements are always incorrect
7) use hashed tables instead of standard tables. They are faster
no, use sorted tables, hashed are very special and can only be used if there is a unique key
8) avoid the use of collect as much as you can.
total nonsense, use collect with hashed tables, works perfect, if you use it with standard tables, do not mix it with other statements
1 Always check the driver internal tables is not empty , while using FOR ALL ENTRIES
100% correct
2 Avoid for all entries in JOINS
... not generally true
3 Try to avoid joins and use FOR ALL ENTRIES.
... hmmm, there are pages of discussions, this statement was wrong, is wrong and will be wrong!!!
4 Try to restrict the joins to 1 level only ie only for 2 tables
nonsense, joins are complicated, you must know hw indexes are used, if everything is fine, then 10 or 20 tables can be joined
5 Avoid using Select *.
see 4)
6 Avoid having multiple Selects from the same table in the same object.
... try to avoid to SELECT the same data, different criteria can be necessary
7 Try to minimize the number of variables to save memory.
... obvious,
8 The sequence of fields in 'where clause' must be as per primary/secondary index ( if any)
... no is must not the optimizer will not be influenced be the order , but do it, it increases readability
9 Avoid creation of index as far as possible
... no, o.k. if you are not experienced than avoid ... otherwise the creation of the required indexes is absolutely mandatory for new tables, for SAP standard tables most indexes are already there. But still if very new accesses are added, then new indexes can become necessary.
10 Avoid operators like , > , < & like % in where clause conditions
... no, you must add them, but be aware that the search is only poorly supported by them, but the result set is reduced.
11 Avoid select/select single statements in loops.
... if they are going to the database! If the tables are buffered, then these statements are perfect!
12 Try to use 'binary search' in READ internal table. Ensure table is sorted before using BINARY SEARCH.
.... Actually try to avoid standard tables, use sorted tables instead. If you must use a standard table, than the recommendation is true.
13 Avoid using aggregate functions (SUM, MAX etc) in selects ( GROUP BY , HAVING,)
.... no, use them if required. Again, if table is buffered, then they MUST be avoided.
14 Avoid using ORDER BY in selects
... if it is not ORDER BY PRIMARY KEY. Again, if the table is buffered, then other orders MUST be avoided.
15 Avoid Nested Selects
... use join. Again, if the tables are buffered, then Nested SELECTs are fine!
16 Avoid Nested Loops of Internal Tables
.... impossible, there is no other option. Use sorted tables and verything is fine!
17 Try to use FIELD SYMBOLS.
... what means try? Use ASSIGNING fieldsymbol in LOOPs, but use it in READs only for very wide tables (>1kB). Use it always for tables with tables in the workarea!
18 Try to avoid into Corresponding Fields of
... see 6) is wrong!
19 Avoid using Select Distinct, Use DELETE ADJACENT.
.... no, use it if required and if it can reduce the result set by a factor of 2 or more. Again, if table is buffered, then it MUST be avoided.
Wenn Sie mit der Performance Ihres ABAP Programms nicht zufrieden sind, werfen Sie doch einen Blick in mein neues Buch:
Siegfried Boes: Performance-Optimierung von ABAP®-Programmen Nov. 2009 464 Seiten 59u20AC
Leseproben und weitere Informationen: http://www.dpunkt.de/buecher/3096.html
Edited by: Thomas Zloch on Dec 3, 2010 10:53 AM -
Adding code in ABAP Query(ABAP HR)
I have created an ABAP Query for getting the Absence details of employee within a specified period.I am populating the fields
Employee number, Organization Unit,Absence start date,Absence hours, Absence enddate.
If an employee is in leave for 10 days, this information will be stored in PA2001 table,and this table is not Organization specific.
During the specified period(20 days), if an employee is under two Organization units(5 days in 1st Org Unit,15 days in 2nd Org Unit). The query is extracting two records for the same employee, because of two Organization units. And while populating the data, the query is getting the Absence information from PA2001 table, and this is causing overlapping of data. So it is showing the Absence details for that employee as 40 days(20 days in 1st Org Unit and 20 days in 2nd Org Unit,Instead of total 20 days). So i would like to add validation over here after extraction of data from the PA2001 table,before displaying the data.
I have tried adding the code in the infoset, at END OF SELECTION Event,but i am not able to change the list, as i am not able to access the tables used by the Query.
Can anybody suggest me where to add the code in the Query, so that i will be able to solve this issue, instead of changing the code in the Report program generated by the Query.you can look at BAPI_PTIMEOVERVIEW_GET
this gives the output back for the selected period so you don't get alle the records back from you're pa2001 table. (only this overview doesn't take into considerationd the distiction the difference between leave and illness)
further on if you consider using the pa2001 table you can loop through the begda and endda and add 1 day for each record and programm the logic how you want to intrepet each day you'reself
I use the data from perws which comes from the function HR_PERSONAL_WORK_SCHEDULE
(which is also used in the BAPI mentioned above)
and from PA0001 you can retrieve how long somebody was in 1 org unit !!
LOOP AT it_2001 WHERE begda BETWEEN i_begda AND i_endda
OR endda BETWEEN i_begda AND i_endda.
h_datum = it_2001-begda.
IF it_2001-awart BETWEEN '0100' AND '0199'.
WHILE h_datum <= it_2001-endda.
READ TABLE it_perws WITH KEY datum = h_datum.
IF sy-subrc = 0.
* you're logic
ENDIF.
CALL FUNCTION 'FKK_DTE_ADD'
EXPORTING
i_base_date = h_datum
i_periode = 'D'
i_period_factor = 1
* I_USE_FACCAL = ' '
* I_WORKDAY_INDICATOR = '-'
IMPORTING
e_datum = h_datum
* EXCEPTIONS
* ERROR_OCCURED = 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.
ENDWHILE.
kind regards
arthur de smidt
Edited by: A. de Smidt on Jul 16, 2008 8:47 AM
Maybe you are looking for
-
Start routine to check for BUDAT in 2LIS_02_SCL
HI, I'm pulling data from 2lis_02_scl and 2lis_02_acc datasources into an ODS. I want to write a start routine that will check if there is any value for BUDAT field (posting date) in the 2lis_02_scl datasource. I want to get data into the ODS only if
-
User-exit / Badi for changin vendors(fk01/02) and customers(fd01/02)
Hi, I'm looking for an user-exit or an Badi which can be used, when creating/changing a vendor or customer. Has anybody used it? Thanks. Regards, Dieter
-
Frozen and lost photo's!?!?
i just imported 200 so photo's into iPhoto but after the import i was rotating some and the program crashed, when i re-opened it the photo's i just imported were not there. As usual i had selected the option to delete the photo's from my camera after
-
If_wd_window_manager
I want to create a popup window with three buttons -- Replace Revise and Cancel. Is it possible to use an instance of the if_wd_window_manager to do this, or can I only display buttons like Yes No Cancel?
-
Win7 64 bit. Think I've seen this before, and had to reinstall Photoshop. Is there a real fix yet ? cheers, Maurice