Query on Batch
Hi Guys,
i need your suggestion for a query i'm creating.
this query is needed to retrieve data regarding the stock.
now i've created a query based on table MCHB MCH1 MAKT MSEG
my customer wants that all the batches that have been used and have not a stock balance should be excluded from the results.
my query extracts also the mov. type and i can include a new field to add the - symbol but the batches are not excluded because the movement type have a quantity.
so i've tried to add the MARD table to have the stock but the query extract the same values for all the batches for example:
material xxxxxx with 3 batches 1 2 and 3
batch 1 is empty batch 2 is empty and batch 3 has 10 kg.
now my query will extract this material with this batches with all the movement type but with stock 10 kg for all the batches.
do you have any idea? how can i exclude all the batches that have stock 0?
thanks
C.
i've resolved my issue, i've added a new custom field with an if
IF MSEG-BWART = '601'." OR MSEG-BWART = '261'
QUANTIT1 = ( -1 ) * MSEG-ERFMG.
THANKS FOR YOUR REPLY
Similar Messages
-
Hi,
I am using BW MDX Driver to report off SAP BW data. Sometimes the returned data may be too much according to user selection. My question is, is there any way to run the MDX query in batch, so that the data is not returned all at once?
For opensql or infoset driver, we can configure the query to run in batch by adding some system environment variables. But for MDX, I have no idea now.
Thanks,
RayHi,
Are you including the parameter that you must have created in Crystal Reports in the Select Expert. You need to include the parameter within the record selection or group selection formula of the Select Expert, as may be applicable. Only then the values returned by the database would be in accordance to the input by the user.
For instance, let us assume that you have created the Country parameter in Crystal Reports. In order to return data as per input fed within the County parameter during Report Refresh, the formula in Select Expert would be somewhat like :
{Customer.Country} = {?Country}
Please do this preliminary check before thinking of using Open SQL or InfoSet driver instead of the MDX driver or feeding the environment variables through batch processing.
Regards,
Amogh. -
Query on Batch Determination in Production Order
Dear Gurus
I have one query on batch determination in production order against the scenario given below, which need your help .
We know that it is possible to allocate the same component batch to two concurrent production orders at the same time in SAP. But as per the business requirement its not possible physically. So business want to update the batch selection logic to exclude the already allocated batch to any open production order.
In my understanding it cant be done without any enhancement, but require your expert opinion before coming to any conclusion.
If you have any idea to achieve the solution kindly let me know.
ThanksDear
I am not sure whether you can change the Batch SELECTION logic for concurrent production order .As far as I know batch selection is done on Batch search strategy /sort Rule
Explore SAP Help : http://help.sap.com/printdocu/corePrint46c/en/data/pdf/LOBM/LOBM.pdf
Refer this useful thead from expert :Userexit in Batch determination and external number ranges for batches
Regards
JH -
Batch Query with Batch but need address lines split by column
Hi folks,
I have the following query I created with the batch number of the sales order:
SELECT T0.[DocDate] as "Date", T1.[DocNum] as "Sales Order Number", T0.[CardCode] as "Customer Code", T0.[CardName] as "Customer Name",T1.[Address2], T0.[ItemCode], T0.[ItemName], T0.[BatchNum], T0.[Quantity], T1.pickrmrk FROM IBT1 T0, ORDR T1 WHERE T0.[BaseNum] = T1.[DocNum] and T1.docstatus = 'O' and T0.WHSCODE = '01' order by T0.BaseNum
Now I need to split the address by column so need street, block, city, county, country and zipcode fields from CRD1, but would either need the ship to address of the sales order it is selected or even just the default ship to address of the sales order. In above query T1.[Adress2] is not quite right for our needs, as this file will have to be exported to 3rd party. So I have gotten this far:
SELECT T0.[DocDate] as "Date", T1.[DocNum] as "Sales Order Number", T0.[CardCode] as "Customer Code", T0.[CardName] as "Customer Name",T1.[Address2], T2.[Street], T2.[Street], T2.[Block], T2.[City], T2.[County], T2.[Country], T2.[Zipcode], T0.[ItemCode], T0.[ItemName], T0.[BatchNum], T0.[Quantity], T1.pickrmrk FROM IBT1 T0, ORDR T1, CRD1 T2 WHERE T0.[BaseNum] = T1.[DocNum] and T1.docstatus = 'O' and T0.WHSCODE = '01' and T0.[CardCode] = T2.[CardCode] and T2.[AdresType] = 'S' order by T0.BaseNum
but will split into multiples if a business partner have more than one shipping address.
Can someone please advise on this one?
Many thanks in advance,Thanks Agustin, tried it with RDR12 as the following query:
SELECT T0.[DocDate] as "Date", T1.[DocNum] as "Sales Order Number", T0.[CardCode] as "Customer Code", T0.[CardName] as "Customer Name",T1.[Address2], T2.[StreetS], T2.[BlockS], T2.[CityS], T2.[ZipCodeS], T2.[CountyS], T2.[CountryS], T2.[ZipCodeS], T0.[ItemCode], T0.[ItemName], T0.[BatchNum], T0.[Quantity], T1.pickrmrk FROM IBT1 T0, ORDR T1, RDR12 T2 WHERE T0.[BaseNum] = T1.[DocNum] and T1.docstatus = 'O' and T0.WHSCODE = '01' order by T0.BaseNum
but has multiple lines for different addresses (and not just shipping addresses of that businss partner sales order).
Anymore ideas or can you spot error in the query?
Thanks again, -
Help needed in consuming BTQueryAUI query in batch mode
Hi Friends,
I am trying to consume BTQueryAUI in a custom function module. I have a requirement where in when i receive a external ref nbr, i need to update the status of crm service request to completed. We have already built logic to store the external nbr info in AET field on Service request and enhance inbox search to take give the results accordingly. now when i try to consume the query service with standard query parameters in batch mode..its not working..
REPORT ZTEST_CSOCRM.
DATA : ob_oref TYPE REF TO zcl_im_z_badi_inbox_search,
C_ITEM_1O TYPE CRMT_AUI_MAP_ITEM_TYPE VALUE 'ONEORDER',
l_param1o_tab TYPE crmt_name_value_pair_tab,
is_name type standard table of CRMT_NAME_VALUE_PAIR,
wa_name like line of is_name,
l_sort_1o_tab TYPE crmtt_aui_sorting,
lv_result_1o TYPE REF TO cl_crm_bol_entity_col.
data QUERY_1O type ref to CL_CRM_BOL_QUERY_SERVICE.
CONSTANTS:
abap_true TYPE abap_bool VALUE 'X',
abap_false TYPE abap_bool VALUE ' '.
data: c_BTQueryAUI TYPE crmt_ext_obj_name
VALUE 'BTQueryAUI',
c_query1o TYPE crmt_ext_obj_name VALUE 'BTQueryAUI',
ob_query TYPE REF TO
cl_crm_bol_query_service,
ob_result TYPE REF TO if_bol_bo_col,
ob_core TYPE REF TO cl_crm_bol_core,
lr_aui_dq TYPE REF TO cl_crm_aui_advquery_service,
lr_aui type ref to cl_crm_aui_query_service.
wa_name-name = 'ASSIGNEDTYPE'.
wa_name-value = '0000'.
append wa_name to is_name.
wa_name-name = 'DATETYPE'.
wa_name-value = '0001'.
append wa_name to is_name.
wa_name-name = 'MAINCATEGORY'.
wa_name-value = 'ZBGW'.
append wa_name to is_name.
wa_name-name = 'SORTEDBY'.
wa_name-value = '0000'.
append wa_name to is_name.
wa_name-name = 'SORTEDBY2'.
wa_name-value = '0000'.
append wa_name to is_name.
wa_name-name = 'TIMEPERIOD'.
wa_name-value = '0000'.
append wa_name to is_name.
wa_name-name = 'ZZFLD000006'.
wa_name-value = '0000012345'.
append wa_name to is_name.
wa_name-name = 'DESCRIPTON'.
wa_name-value = '*test*'.
append wa_name to is_name.
l_param1o_tab = IS_NAME.
ob_core = cl_crm_bol_core=>get_instance( ).
ob_core->start_up( 'ALL' ).
TRY.
query_1o = cl_crm_bol_query_service=>get_instance( c_query1o ).
CATCH: cx_crm_unsupported_object.
ENDTRY.
query_1o->set_query_parameters( EXPORTING it_parameters = l_param1o_tab
iv_convert = abap_false ).
lv_result_1o ?= query_1o->get_query_result( ).
ob_query = cl_crm_bol_query_service=>get_instance( c_BTQueryAUI ).
ob_query->set_query_parameters( EXPORTING it_parameters = l_param1o_tab
iv_convert = abap_false ).
lv_result_1o ?= ob_query->get_query_result( ).Tried obtaining the output using SQL and the result is as follows:
SQL> WITH T AS
2 (
3 SELECT 1 COL1 FROM DUAL
4 UNION
5 SELECT 2 COL1 FROM DUAL
6 UNION
7 SELECT 3 COL1 FROM DUAL
8 UNION
9 SELECT 4 COL1 FROM DUAL
10 UNION
11 SELECT 5 COL1 FROM DUAL
12 UNION
13 SELECT 8 COL1 FROM DUAL
14 UNION
15 SELECT 9 COL1 FROM DUAL
16 UNION
17 SELECT 10 COL1 FROM DUAL
18 UNION
19 SELECT 13 COL1 FROM DUAL
20 UNION
21 SELECT 14 COL1 FROM DUAL
22 UNION
23 SELECT 15 COL1 FROM DUAL
24 UNION
25 SELECT 16 COL1 FROM DUAL
26 UNION
27 SELECT 23 COL1 FROM DUAL
28 UNION
29 SELECT 24 COL1 FROM DUAL
30 )
31 SELECT OUTPUT FROM
32 (
33 SELECT DECODE(COL3,NULL,COL1, COL2) || '-' || LEAD(DECODE(COL3,NULL,COL3, COL1)) OVER (ORDER BY DECODE(COL3,NULL,COL1, COL2)) OUTPUT FROM
34 (
35 SELECT COL1, LEAD(COL1) OVER (ORDER BY COL1) COL2, LAG(COL1) OVER (ORDER BY COL1) COL3 FROM T
36 )
37 WHERE
38 (COL2 - COL1 > 1 OR COL2 IS NULL OR COL3 IS NULL)
39 )
40 WHERE OUTPUT != '-';
OUTPUT
1-5
8-10
13-16
23-24 -
Query on batch number in Invoice
Hi Experts,
I would like to get the batch number picked during the Delivery document and shown in the print layout in A/R Invoice. Unfortunately, PLD of Invoice with Batch will not show the Batch numbers as they're already linked in the DR document.
My workaround is to attach a FMS in the INV1 field line to get the batch number when the Invoice is copied from the DR.
Any help with the query is very much appreciated.
We are using 8.81 PL7.
Thanks,
DonHi Don..........
Please check this........
Select (Case When T1.BaseType=15 then I1.BatchNum else I11.BatchNum end) 'BatchNum', T0.DocNum 'Inv. No'
FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OCTG T2 ON
T0.GroupNum = T2.GroupNum LEFT Join INV12 T3 On T3.DocEntry=T0.DocEntry LEFT JOIN OITM T4 On T4.ItemCode=T1.ItemCode LEFT JOIN OCHP T5 On T4.ChapterID=T5.AbsEntry
LEFT Join DLN1 T6 On T6.DocEntry=T1.BaseEntry and T6.LineNum=T1.BaseLine
left outer join IBT1 I1 on T1.ItemCode=I1.ItemCode and (T6.DocEntry=I1.BaseEntry and T6.ObjType=I1.BaseType)
left outer join OBTN T8 on T8.ItemCode=I1.ItemCode and I1.BatchNum=T8.DistNumber
LEFT Join WTR1 T16 On T16.DocEntry=T1.BaseEntry and T16.LineNum=T1.BaseLine
left outer join IBT1 I11 on T1.ItemCode=I11.ItemCode and (T16.DocEntry=I11.BaseEntry and T16.ObjType=I11.BaseType)
left outer join OBTN T18 on T18.ItemCode=I11.ItemCode and I11.BatchNum=T18.DistNumber
LEFT Outer Join OWHS T20 On T20.WhsCode=T0.Filler
Run this query you get Invoice No. and its Batch.....
You may insert required c0olumns also.....
Regards,
Rahul -
Query on batch jobs with overlapping time during execution time
Dear experts,
This post is related to a task in SAP SCM EM module and currently I am working on an archival activity that comprises of two tasks to be done through 2 different programs (scheduled through batch jobs)
Job 1 is created to deactivate particular Event Handler records (changing a status field on the EH record)
Job 2 (archival job) runs daily and writes deactivated EHs to a local file and subsequently deletes this from SAP server.
Archival job takes an average of 30 hrs to complete .
Therefore my query is on how to schedule Job1, as these seem to be dependent and might impact each other in unexpected manner.
Please advise.
Thanks & regards,
MohanHi Mohan,
You can try as Daniel suggested. Delay Archieving job or can run after deactivating Event Handler records job is finished. Check any parallel processing is available or not.
It can stop your overlapping issue and can increase your performance.
Thanks,
Bala. -
I have just created batch file with the below code
FOR /F "usebackq delims=!" %%i IN (`sqlplus -s usr/pwd@orclprd @runquery.sql`) DO set var_x=%%i
rem @echo on
echo "value of var_x " is %var_x%
Trying to get the value of variable x from the query which is in runquery.sql(select status from table1 where id=20292;)
but when i execute the batch file ,it got stuked and not giving or printing the value of 'X';
Do i need to add or modify any thing else to get the X Value????Wrong forum but this is what I do to get variables back....
sqlplus -L -S %user%/%pw%@%host% @sp\oracle\sp_etl_rollback.sql > connect.logThe results of this connection test is put into the connect.log file (the greater than (>) symbol is a assignment operator to assign whatever it gets from the buffer on that query into the file).
Then just use any FOR /F look to get the value from the .log file.
Here is an example I use to find a certain ID:
echo set echo off newpage 0 space 0 pagesize 0 feed off head off trimspool on linesize 4096 serveroutput on > temp.sql
echo select count(*) from d_grid where grid_id = '%grid%'; >> temp.sql
echo exit; >> temp.sql
sqlplus -S %user%/%pw%@%host% @temp.sql > result.dat
for /f %%x in ('more result.dat') do set exists=%%x
IF '%exists%'=='0' goto :NO_GRID
IF '%exists%'=='1' IF '%undo_type%'=='1' goto :GET_DATE
IF '%exists%'=='1' IF '%undo_type%'=='2' goto :ORA_GET_BATCH
IF '%exists%' GTR '1' (
SET errormsg=Two separate grid entries contain the same name!!
goto :ERROR )TimS -
Advise on sql query for batch job
Hi all,
I'm planning to perform a batch query for 4000 records.
The query is as follows and we will loop it for 4000 times.
select w.idno, w.place, e.user_arrival_dt from main.tbl_user w, main.tbl_job e
where w.idno = e.idno and w.idno = <idno>
I find that rather inefficient in term of performance.
I can use the below too but the the in clause has a limit.
select w.idno, w.place, e.user_arrival_dt from main.tbl_user w, main.tbl_job e
where w.idno = e.idno and w.idno in <idno1, idno2, idno3, idno4, etc>
Another way that I can think of is to loop for 10 times and use this query
select w.idno, w.place, e.user_arrival_dt from main.tbl_user w, main.tbl_job e
where w.idno = e.idno and w.idno in <idno1, idno2, idno3, idno4, until idno400>
is there any other more efficient way of coding to achive the above?
kindly advise.
thanks!Hi,
Qwerty and Surachart are right; the best way is to put the 4000 values into 4000 rows of a table (perhaps a Global Temporary Table) and use a sub-query.
If you really must have 4000 literals, then you can have 4000 items in a list like this:
where w.idno = e.idno
and (w.idno, 0) IN ( (idno1, 0)
, (idno2, 0)
, (idno3, 0)
, (idno4000, 0)
)See [this thread|http://forums.oracle.com/forums/thread.jspa?messageID=3508573�] for discussion. -
Hi
i want query that
suppose i create 'i01' item make management method by batch.
when i create ap invoce at that time i add vendor refrence number add add that 'i01'
item with '5' quantity's then add. at that time it ask for batch update.
then i get new window of batch OBTN in that window i make user defined field.
"In that user defined field i want that vendor reference number which i give in ap invoce "
so plz help ..................Hi,
Unless I misunderstood your question (if so, sorry), I presume you mean formatted-search to copy vendor reference number from main A/P Invoice form to batch selection form, isn't it? You can't do this, formatted search works in one form, can't work across two form / document. Hope this help.
Best Regards,
Hendry Wijaya -
QUERY WITH BATCH IN SAPB1 8.81
DEAR ALL,
we have a query and this works ok in 2007A, but when our customer update at 8.81 doesnt work, could you helpeme please?.
I dont know what happen if this query have an other definition in 8.81. we have to change something?. now this dont work and when w run it thakes 5o gigas in hard disk.
i hoppe your soon support.
T2.[PrdDate], T2.[ExpDate], T2.[Located], T2.[Quantity] as 'Kilos obtenidos', T2.[U_Grasa], T2.[U_PH], T2.[U_Acidez], T2.[U_PROT], T2.[U_VOLUMEN], T2.[U_RENDIM], T2.[U_HUMEDAD] FROM OWOR T0 INNER JOIN IGN1 T1 ON T0.[DOCNUM]=T1.[BASEENTRY]
INNER JOIN OIBT T2 ON T1.[DOCENTRY]=T2.[BASENUM]
INNER JOIN WOR1 T3 ON T0.[DOCNUM]=T3.[DOCENTRY]
INNER JOIN OITM T4 ON T3.[ITEMCODE]=T4.[ITEMCODE] WHERE T0.[PostDate] >=[%0] AND T0.[PostDate] <=[%1]Hi,
I ran the following and was not getting any error/problem with the query :
select T2.PrdDate, T2.ExpDate, T2.Located, T2.Quantity
--T2.U_Grasa, T2.U_PH, T2.U_Acidez,
--T2.U_PROT, T2.U_VOLUMEN, T2.U_RENDIM, T2.U_HUMEDAD
FROM OWOR T0
INNER JOIN IGN1 T1 ON T0.DOCNUM=T1.BASEENTRY
INNER JOIN OIBT T2 ON T1.DOCENTRY=T2.BASENUM
INNER JOIN WOR1 T3 ON T0.DOCNUM=T3.DOCENTRY
INNER JOIN OITM T4 ON T3.ITEMCODE=T4.ITEMCODE WHERE T0.PostDate >= '2006.01.01' AND T0.PostDate <= '2006.12.31'
Please check the UDF's and if you are getting any error do let us know.
Kind Regards,
Jitin
SAP Business One Forum Team -
Run sql query through batch file
how to create a batch file so that on running the batch file,
I should get into the database using username and password and create the table and insert values inside that tablekindly, if you are using windows you can create 2 files as following:
a.bat
b.sql
put the files under spacific folder for example d:\bat folder
-first file a.bat will contain the following:
sqlplus apps/apps@yourdb @d:\bat\B.sql
exit
-second file b.sql will contain any sql statments you want as following:
create table a (a1 number, a2 varchar2(100))
insert into a (a1,a2) values(1,'Test')
commit
exit;
hope this help you
Regards ...
Edited by: shedo76 on 28/04/2012 03:14 ص -
Hi experts
I found that I can assign a external batch number to a material manually,but in background I have not assigned an external number range for batch, who can tell me that's why?
thank you!Hi,
It is not relevant with No. Range of Batch
Go to SPRO > Logistics - General > Batch Management > Creation of New Batches > Define Initial Creation of Data for Batch Master Transactions > Here for Material Type select option as "C" (Automatic / No Manual)
Also check in SPRO > Logistics - General > Batch Management > Creation of New Batches > Define Batch Creation for Goods Movements > Here for Movement Type select option as "C" (Automatic / No Manual) -
Query on batch scripting - Archival
Hello,
I am totally new to batch script. Below is the requirement that needs to be developed using batch script. Please suggest on how to proceed and a good link to learn about batch scripting too.
Zip once in 2 weeks and deleted after a year.
Thanks and Regards,Hello,
You can use PowerShell to automate the job of Zip and delete them based on scheduled time lines. -
Pass variables from dialogue query to batch planning functions
The requirement.
The user will open an u2018open-for-inputu2019 query (Web Template) using a number of variables (some are type exit). After entering data, the user will close the process by saving the data. The u2018Saveu2019 button will start a Planning Sequence which includes open data slice, distribution, copy, repost function and close data slice. The user will not wait for any feedback from these processes so they should be done as back-ground processes (in any case the dialogue process will time out).
The problem.
The background process will be started from the query u2018Saveu2019 button. This is easy enough to do.
However it is absolutely vital that the variables are passed from the query (which may or may not still be active) to the same variables that will need to be filled in the Planning Functions in the background process. I imagine that the background process will be a Process Chain .
Help needed.
1. Can anyone give me the way in which this is done?
2. It could be critical that the user does get feedback in some form or other if the back-ground processes fail for whatever reason. Any ideas how this can be achieved at the user interface level. The users will not have 'SAP Savy' and the log in the Process Chain will not be transparent to them.One approach..
Have diff variables for query and planning seq.
Say V1, V2 etc for query and VF1, VF2 etc for data slices and planning functions.
Maintain one Z-table which contains variables V1, V2 etc along with their values.
So when the users select query variables, on save, one exit function will write these variable values to the z-table. The variables used in planning seq and data slices (VF1, VF2..) will be exit variables which read corresponding entries from Z-table (V1, V2...). So background process will run based on what the user has selected.
Maybe you are looking for
-
Is there a way to use SPD workflow to enhance the alert function in a SharePoint list?
I have a request to achieve this: the Alert function in a list only allows a user to get alert when anything changes or created, but there is no way to specify notification before a certain field date. For Example, users want to be able to choose
-
Analytic Workspace Manager 10.2.0.3.0A posted
A new version of Analytic Workspace Manager has been posted to the Oracle OLAP site on OTN and MetaLink. AWM 10.2.0.3.0A addresses the following bugs found in AWM 10.2.0.3.0: 5949796<< Period To Date calculation incorrect when using non-Gregorian tim
-
HT1688 Iphone 3gs can't slide to button to access the phone
I have tried to reboot by holding power and home button. Also installed the latest update. Still can't slide the button on the screen. Also can't slide the button to turn off the phone. What can I do to fix this? Thanks.
-
Oracle 11GR1 clusterware compatibility.
Hi I have 11GR2 db on my system, I want to convert into 11G RAC. My question is since 11GR2 clusterware is not available for download. Will 11GR1 Clusterware software do the job or shall i download 11GR1 database software ?? Thanks in Advance.
-
Bootcamp won't see windows disc, even as an administrator
Have downloaded windows 8 and burned to dvd as iso and as decompressed, also have put it on an 8gb usb stick. Bootcamp instructions and help say that if it cant find the windows8 disc make sure you are logged on as an administrator, well i have done