Fetch and Closing a Cursor
Listed below is my code. I get the following errors when trying to execute
Error(35,29): PLS-00103: Encountered the symbol "@" when expecting one of the following: mod <an identifier> <a double-quoted delimited-identifier> <a bind variable> current sql execute forall merge pipe
on this block [BEGIN
OPEN source_table;
FETCH source_table INTO @FIN;]
Please any ideas will be helpful.
create or replace
PROCEDURE CHP_ENCOUNTER_LOAD
AS
** Cursor method to cycle through the DWFILENCOUNTER table and get DWFILENCOUNTER Info for each iRowId.
** Revision History:
** Date Name Description Project
** 07/20/10 ¿-
BEGIN
DECLARE CURSOR source_table IS
SELECT DISTINCT
SI.FIN
FROM
CHP_SURG_INFECTION SI;
-- Declare all Variables ***********
--DECLARE
dblPatient_ID int;
dblOrganization int;
-- Get rows from source table (CHP_SURG_INFECTION) into cursor
--SET NOCOUNT ON
BEGIN
OPEN source_table;
FETCH source_table INTO @FIN
--...bunch more fields here...
--This is where you perform your detailed row-by-row processing.
WHILE @@Fetch_Status = 0
****** Avoid Duplicates Section
-- Select to see if Encounter already exists (FIN exists on the DWFILENCOUNTER table)
SELECT E.FIN
FROM DWFILENCOUNTER E
WHERE E.FIN = @FIN
-- Loop onto next row if already found
IF SQL%NOTFOUND THEN
goto end_loop;
END IF;
******* Lookup Section ************
-- PATIENT - Select Patient from Patient Table (MRN exists on the DWFILPATIENT Table)
SELECT P.Patient_ID into dblPatient_ID
FROM DWFILPATIENT P
WHERE P.MRN = @MRN;
-- Log out Error if Patient Not found and Loop to next Record (don't insert)
IF SQL%NOTFOUND THEN
goto end_loop;
END IF;
-- ORGANIZATION - Select Organization from the DWOrganization table based on name
SELECT O.Organization_Id into dblOrganization_ID
FROM DWDIMORGANIZATION O
WHERE O.ORG_NAME = @FACILITY;
-- Log out Error if Organization Not found and Loop to next Record (don't insert)
IF SQL%NOTFOUND THEN
goto end_loop;
END IF;
**** Insert Rows *********************************
-- Inserting columns in the DWFILENCOUNTER table
INSERT INTO DWFILENCOUNTER (ENCOUNTER_TYPE, FIN, PATIENT_ID, ORGANIZATION_ID )
VALUES (@ENCOUNTER_TYPE, @FIN, dblPatient_ID, dblOrganization_ID)
-- Commit
¿- Get the next row.
FETCH
<<end_loop>>
END
LOOP
CLOSE source_table
DEALLOCATE source_table
RETURN
END CHP_ENCOUNTER_LOAD;
Sory for not posting the right code. Here is the code with all vriable included.
create or replace
PROCEDURE CHP_ENCOUNTER_LOAD
AS
** Cursor method to cycle through the DWFILENCOUNTER table and get DWFILENCOUNTER Info for each iRowId.
** Revision History:
** Date Name Description Project
** 07/20/10 ¿-
--SET NOCOUNT ON
-- Declare all Variables ***********
DECLARE
@dblPatient_ID int;
@dblOrganization int;
@FIN VARCHAR2(50 BYTE);
@MRN VARCHAR2(25 BYTE);
@FACILITY VARCHAR2(50 BYTE);
@ENCOUNTER_TYPE VARCHAR2(50 BYTE);
CURSOR source_table FOR
BEGIN
-- Get rows from source table (CHP_SURG_INFECTION) into cursor
SELECT DISTINCT
SI.FIN
SI.ENCNTR_TYPE
FROM
CHP_SURG_INFECTION SI;
OPEN source_table
FETCH source_table INTO
@FIN,
@MRN,
@FACILITY,
@ENCOUNTER_TYPE
--...bunch more fields here...
--This is where you perform your detailed row-by-row processing.
WHILE @@Fetch_Status = 0
BEGIN
--****** Avoid Duplicates Section
-- Select to see if Encounter already exists (FIN exists on the DWFILENCOUNTER table)
SELECT E.FIN
FROM DWFILENCOUNTER E
WHERE E.FIN = @FIN
-- Loop onto next row if already found
IF SQL%NOTFOUND THEN
goto end_loop;
END IF;
--******* Lookup Section ************
-- PATIENT - Select Patient from Patient Table (MRN exists on the DWFILPATIENT Table)
SELECT P.Patient_ID into dblPatient_ID
FROM DWFILPATIENT P
WHERE P.MRN = @MRN;
-- Log out Error if Patient Not found and Loop to next Record (don't insert)
IF SQL%NOTFOUND THEN
goto end_loop;
END IF;
-- ORGANIZATION - Select Organization from the DWOrganization table based on name
SELECT O.Organization_Id into dblOrganization_ID
FROM DWDIMORGANIZATION O
WHERE O.Name = @FACILITY;
-- Log out Error if Organization Not found and Loop to next Record (don't insert)
IF SQL%NOTFOUND THEN
goto end_loop;
END IF;
--**** Insert Rows *********************************
-- Inserting columns in the DWFILENCOUNTER table
INSERT INTO DWFILENCOUNTER (ENCOUNTER_TYPE, FIN, PATIENT_ID, ORGANIZATION_ID )
VALUES (@ENCOUNTER_TYPE, @FIN, @dblPatient_ID, @dblOrganization_ID)
-- Commit
-- Get the next row.
FETCH
<<end_loop>>
END
LOOP
CLOSE source_table
DEALLOCATE source_table
RETURN
END CHP_ENCOUNTER_LOAD;
Similar Messages
-
I have a drag image application and I wanted to use the open and closed hand cursors to move the image about. It seems there is no easy way of accessing these in Java. After searching for cursor names etc.. I decided to hard code the cursors from the .gif image. Also I didn't want the .GIFs as files as this adds to loading problems so I ended up using arrays of pixels that took a little while to enter.
I'm giving you the code if you ever need to use it as I typed it in and wouldn't want anyone else to have to do the same.
int curWidth=32;
int curHeight=32;
int curCol;
Image img;
int x,y;
int closed_black[] = { 6,5,7,5,9,5,10,5,12,5,13,5,5,6,8,6,11,6,14,6,
15,6,5,7,14,7,16,7,6,8,16,8,5,9,6,9,16,9,4,10,
16,10,4,11,16,11,4,12,15,12,5,13,15,13,6,14,14,14,
7,15,14,15,7,16,14,16,0};
int closed_white[] = { 6,4,7,4,9,4,10,4,12,4,13,4,5,5,8,5,11,5,14,5,15,5,
4,6,6,6,7,6,9,6,10,6,12,6,13,6,16,6,4,7,15,7,17,7,
5,8,17,8,4,9,17,9,3,10,5,10,15,10,17,10,3,11,17,11,
3,12,16,12,4,13,16,13,5,14,15,14,6,15,15,15,6,16,
15,16,7,17,14,17,0};
int closed_whiteruns[] = {6,13,7,15,7,15,5,15,5,15,5,14,6,14,7,13,8,13,8,13,0};
int open_black[] = { 10,3,11,3,6,4,7,4,9,4,12,4,13,4,14,4,5,5,8,5,9,5,12,5,
15,5,5,6,8,6,9,6,12,6,15,6,17,6,6,7,9,7,12,7,15,7,16,7,18,7,
6,8,9,8,12,8,15,8,18,8,4,9,5,9,7,9,15,9,18,9,3,10,6,10,7,10,
18,10,3,11,7,11,17,11,4,12,17,12,5,13,17,13,5,14,16,14,6,15,
16,15,7,16,15,16,8,17,15,17,8,18,15,18,0};
int open_white[] = {10,2,11,2,6,3,7,3,9,3,12,3,13,3,5,4,8,4,10,4,11,4,15,4,
4,5,6,5,7,5,10,5,11,5,13,5,14,5,16,5,17,5,4,6,6,6,7,6,10,6,
11,6,13,6,14,6,16,6,18,6,5,7,7,7,8,7,10,7,11,7,13,7,14,7,17,7,
19,7,4,8,5,8,7,8,8,8,10,8,11,8,13,8,14,8,16,8,17,7,19,8,3,9,6,9,
16,9,17,9,19,9,2,10,4,10,5,10,19,10,2,11,18,11,3,12,18,12,4,13,
18,13,4,14,17,14,5,15,17,15,6,16,16,16,7,17,18,17,7,18,16,18,
8,19,15,19,0};
int open_whiteruns[] = {9,14,8,17,4,16,5,16,6,16,6,15,7,15,8,14,9,14,9,14,0};
int pix[] = new int[curWidth*curHeight];
for(y=0; y<=curHeight; y++) for(x=0; x<=curWidth; x++) pix[y+x]=0; // all points transparent
// black pixels
curCol=Color.black.getRGB();
int n=0;
while(closed_black[n]!=0)
pix[closed_black[n++]+closed_black[n++]*curWidth]=curCol;
// white pixels
curCol=Color.white.getRGB();
n=0;
while(closed_white[n]!=0)
pix[closed_white[n++]+closed_white[n++]*curWidth]=curCol;
// white pixel runs
n=0;
y=7;
while(closed_whiteruns[n]!=0) {
for(x=closed_whiteruns[n++];x<closed_whiteruns[n];x++)
pix[x+y*curWidth]=curCol;
n++; y++;
img = createImage(new MemoryImageSource(curWidth,curHeight,pix,0,curWidth));
closedhandCursor = Toolkit.getDefaultToolkit().createCustomCursor(img,new Point(5,5),"closedhand");
for(y=0; y<=curHeight; y++) for(x=0; x<=curWidth; x++) pix[y+x]=0; // all points transparent
// black pixels
curCol=Color.black.getRGB();
n=0;
while(open_black[n]!=0)
pix[open_black[n++]+open_black[n++]*curWidth]=curCol;
// white pixels
curCol=Color.white.getRGB();
n=0;
while(open_white[n]!=0)
pix[open_white[n++]+open_white[n++]*curWidth]=curCol;
// white pixel runs
n=0;
y=9;
while(open_whiteruns[n]!=0) {
for(x=open_whiteruns[n++];x<open_whiteruns[n];x++)
pix[x+y*curWidth]=curCol;
n++; y++;
img = createImage(new MemoryImageSource(curWidth,curHeight,pix,0,curWidth));
openhandCursor = Toolkit.getDefaultToolkit().createCustomCursor(img,new Point(5,5),"openhand");
setCursor(openhandCursor);you need to define openhandCursor and closedhandCursor with your other cursor definitions (I made them default to start with) and then just use setcursor as normal. There must be an easier way to do this!
p.s. thanks to Martin Zvarik for the original code here: http://www.jguru.com/faq/view.jsp?EID=9958Hi,
you can use the same query...Also check the new code after the select..
SELECT BUKRS BELNR GJAHR <b>BSTAT</b>
FROM BKPF
INTO TABLE T_BKPF
WHERE BUKRS = P_BUKRS
AND BSTAT IN ( ' ' , 'A' ) " ' ' - Normal document, A - Parked doc
AND BLART = P_BLART
AND CPUDT IN SO_CPUDT " Selection screen input.
IF NOT T_BKPF[] IS INITIAL.
SELECT BUKRS BELNR GJAHR BUZEI EBELN AUGBL AUGBT
INTO TABLE T_BSEG
FOR ALL ENTRIES IN T_BKPF
WHERE BUKRS = T_BKPF-BUKRS
AND BELNR = T_BKPF-BELNR
AND GJAHR = T_BKPF-GJAHR
AND EBELN IN SO_EBELN " selection-screen input
ENDIF.
LOOP AT T_BKPF.
Parked
IF T_BKPF-BSTAT = 'A'.
WRITE: / T_BKPF-BELNR , ' - Parked'.
process the next record.
CONTINUE.
ENDIF.
Check for Open / Closed.
LOOP AT T_BSEG WHERE BELNR = T_BKPF-BELNR
AND BUKRS = T_BKPF-BUKRS
AND GJAHR = T_BKPF-GJAHR
AND AUGBL <> ' '.
EXIT.
ENDLOOP.
If the return code is 0 then the document is cleared..
IF sy-subrc = 0.
WRITE: / T_BKPF-BELNR , ' - Closed'.
Else the document is not cleared.
ELSE.
WRITE: / T_BKPF-BELNR , ' - Open'.
ENDIF.
ENDLOOP.
Thanks,
Naren -
I have read that, the cursor in a for loop will be opened and closed automatically. Will that be the same in the case of the code given below, where we are declaring the cursor before the for loop ?
-- Code
create or replace procedure test
as
begin
-- some statements
-- begin of another block
declare
cursor v_cursor is Select * from Employee;
begin
for cur in v_cursor loop
-- loop statements
end loop;
end;
end test; -- end of procedure
Thanks in advance ..for more information on cursor for loop follow the link
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/01_oview.htm#767 -
I have some doubts/questions .
What is the difference between open and closed cursor?
Are library cache locks same as parse locks?
What is the difference between latch and mutex?
I would be grateful if experts could answer these questions.
RegardsAlmost correct. The terminology is however nor correct.
Simplistically:
The SQL engine receives a SQL. It attempts a soft parse first. This means looking for an existing cursor in the Shared Pool with the same SQL. This existing cursor can be in use by other sessions. It does not matter - if that cursor is in used (opend by other sessions), or not. It may not be in use at all and simply sitting there in the cache. If such a cursor is found, it is used for that session's SQL - and that session gets a cursor handle (reference/pointer) to that existing cursor.
If the SQL engine does not find an existing cursor to use, it needs to create a brand new cursor in the Shared Pool. This is a hard parse. Again, the session receives a cursor handle for that new cursor created.
And that is it.
You now need to decide how to use that cursor handle. The cursor itself is a program. You have a handle to execute that cursor program. Via its bind interface you can input data to this cursor program. Then execute it and receive (fetch) output of that cursor program.
So the ideal is to re-use the cursor handle again and again.
Basic example: the following is not optimal as the same cursor is opened and closed, opened and closed, for each read from the file. A lot of soft parsing results.
while not-eof( filehandle ) // read data from a file
read file data into var1, var2
open cursor for 'insert into testtab values( :1, :2)' // create a cursor
bind cursor :1 = var, :2 = var2 // bind values to cursor (for insert)
exec cursor // do SQL insert
close cursor
end whileThis is a lot better. A single cursor is used and executed again and again:
open cursor for 'insert into testtab values( :1, :2)' // create a cursor
while not-eof( filehandle ) // read data from a file
read file data into var1, var2
bind cursor :1 = var, :2 = var2 // bind values to cursor (for insert)
exec cursor // do SQL insert
end while
close cursor In this case a single soft/hard parse - and the client uses that cursor handle to execute that cursor (insert data) program again and again. -
Difference of fetching data, into a cursor variable and into a record?
whats the difference of fetching data via cursor, into a cursor variable and into a record.
i feel infact fetching data into cursor variable is more better, and plus lesser lines to code??Can you explain what you mean, preferably with an example? Generally, you fetch data from a cursor, not into one. I'm assuming by "fetching into a record" you mean inserting into a table?
Justin -
MB5B Report table for Open and Closing stock on date wise
Hi Frds,
I am trying get values of Open and Closing stock on date wise form the Table MARD and MBEW -Material Valuation but it does not match with MB5B reports,
Could anyone suggest correct table to fetch the values Open and Closing stock on date wise for MB5B reports.
Thanks
Mohan MHi,
Please check the below links...
Query for Opening And Closing Stock
Inventory Opening and Closing Stock
open stock and closing stock
Kuber -
GL a/c opening and closing balances
Hi All,
Below is my selection screen:
select-options : s_bukrs for bkpf-bukrs obligatory.
parameter : p_gjahr like bkpf-gjahr obligatory.
select-options : s_budat for bkpf-budat,
s_monat for bkpf-monat,
s_hkont for bseg-hkont.
I am displaying the data from tables BKPF, BSEG, KNA1-NAME1, LFA1-NAME1, SKAT-TXT50. I have to fetch Opening and Closing balances for GL a/c's. I am fetching data from table GLT0-HSLVT(opening balance). But unable to get the data for closing balance based on the period given on the selection screen. In my report I am looping on table it_bseg to populate the final internal table. How to get the closing balances's total based on the input.
Please help me.
Thanks,
HarithaHello Haritha,
Try this code by building a function module. This would cover both opening and closing balance.
FUNCTION ZGL_OPENING_CLOSING_BAL_KEYDAT.
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(COMP) TYPE BKPF-BUKRS
*" REFERENCE(DATE) TYPE BKPF-BUDAT
*" REFERENCE(ACCT) TYPE BSEG-HKONT
*" EXPORTING
*" REFERENCE(BALANCE) TYPE BSEG-DMBTR
DATA : COMPANYCODEID LIKE BAPI0002_2-COMP_CODE ,
POSTING_DATE LIKE BAPI0002_4-POSTING_DATE ,
FISCAL_YEAR LIKE BAPI0002_4-FISCAL_YEAR ,
FISCAL_PERIOD LIKE BAPI0002_4-FISCAL_PERIOD .
DATA : ACCOUNT_BALANCES TYPE TABLE OF BAPI3006_4 WITH HEADER LINE.
DATA : BAL TYPE BSEG-DMBTR.
DATA : IV_DATE TYPE D ,
EV_MONTH_BEGIN_DATE TYPE D,
EV_MONTH_END_DATE TYPE D .
DATA : COMPANYCODE LIKE BAPI3006_0-COMP_CODE,
GLACCT LIKE BAPI3006_0-GL_ACCOUNT ,
FISCALYEAR LIKE BAPI3006_4-FISC_YEAR,
CURRENCYTYPE LIKE BAPI3006_5-CURR_TYPE VALUE 10.
DATA : IT_BKPF TYPE TABLE OF BKPF WITH HEADER LINE.
DATA : BEGIN OF IT_BSEG OCCURS 0,
BELNR TYPE BSEG-BELNR,
GJAHR TYPE BSEG-GJAHR,
SHKZG TYPE BSEG-SHKZG ,
DMBTR TYPE BSEG-DMBTR,
END OF IT_BSEG.
COMPANYCODEID = COMP.
POSTING_DATE = DATE.
IV_DATE = DATE.
CALL FUNCTION 'HR_JP_MONTH_BEGIN_END_DATE'
EXPORTING
IV_DATE = IV_DATE
IMPORTING
EV_MONTH_BEGIN_DATE = EV_MONTH_BEGIN_DATE
EV_MONTH_END_DATE = EV_MONTH_END_DATE.
CALL FUNCTION 'BAPI_COMPANYCODE_GET_PERIOD'
EXPORTING
COMPANYCODEID = COMPANYCODEID
POSTING_DATE = POSTING_DATE
IMPORTING
FISCAL_YEAR = FISCAL_YEAR
FISCAL_PERIOD = FISCAL_PERIOD.
IF EV_MONTH_END_DATE NE DATE.
IF FISCAL_PERIOD = 1.
FISCAL_PERIOD = 12 .
FISCAL_YEAR = FISCAL_YEAR - 1 .
ELSE.
FISCAL_PERIOD = FISCAL_PERIOD - 1.
ENDIF.
ENDIF.
COMPANYCODE = COMP.
GLACCT = ACCT.
FISCALYEAR = FISCAL_YEAR.
CALL FUNCTION 'BAPI_GL_ACC_GETPERIODBALANCES'
EXPORTING
COMPANYCODE = COMPANYCODE
GLACCT = GLACCT
FISCALYEAR = FISCALYEAR
CURRENCYTYPE = CURRENCYTYPE
TABLES
ACCOUNT_BALANCES = ACCOUNT_BALANCES.
READ TABLE ACCOUNT_BALANCES WITH KEY FISC_YEAR = FISCALYEAR FIS_PERIOD = FISCAL_PERIOD.
IF SY-SUBRC = 0.
BALANCE = ACCOUNT_BALANCES-BALANCE.
ENDIF.
IF EV_MONTH_END_DATE NE DATE.
SELECT * FROM BKPF INTO TABLE IT_BKPF WHERE BUKRS = COMP AND BUDAT >= EV_MONTH_BEGIN_DATE
AND BUDAT <= DATE.
IF IT_BKPF[] IS NOT INITIAL.
SELECT BELNR GJAHR SHKZG DMBTR
FROM BSEG INTO CORRESPONDING FIELDS OF TABLE IT_BSEG
FOR ALL ENTRIES IN IT_BKPF
WHERE BELNR = IT_BKPF-BELNR AND GJAHR = IT_BKPF-GJAHR AND HKONT = ACCT AND BUKRS = COMP.
ENDIF.
LOOP AT IT_BSEG.
IF IT_BSEG-SHKZG = 'H'.
BAL = BAL - IT_BSEG-DMBTR.
ELSEIF IT_BSEG-SHKZG = 'S'.
BAL = BAL + IT_BSEG-DMBTR.
ENDIF.
ENDLOOP.
BALANCE = BALANCE + BAL.
ENDIF.
ENDFUNCTION.
Raghav -
Opening Stock and Closing Stock Calculation
Hi,
My report requirement is to display the material, opening stock for the lower date, closing stock for the higher date and the in between all stock operations..how to fetch the opening stock and closing stock for a particular material ???.. what are the tables and fields for calculating them??..
Thanks,
Sri
Edited by: Sri on Feb 13, 2009 8:33 AMHi
We have done a similar reports. One showing opening stock/Closing stock and another one showing all the transactions for a particular day. What we did was we developed a program to fetch data from MARD table for unrestricted, blocked & Qulaity stock(Our requirement talks only about these 3 stocks). And we scheduled the program exactly at system time 00.00 hrs with A class job.(today's closing day stock is nothing but tomorrow's opening stock)
And for the second report which needs to pick all the transaction for a particular day, we picked it from MB51 entries. It is nothing but query between MKPF and MSEG.
I hope this helps. -
Opening and closing balance between 2 dates
hi.
i am facing a problem while fetching the opening and closing balance for a particular G/L account.
In my program i am entering G/L account for a date range i.e, between two dates and i want opening and closing balance for these 2 date ranges.
So, please tell me is there any function module to fetch opening and closing balance between two dates.
Regards,
ROHINI.K.Hi Rohini,
Check this FM : BAPI_GL_GETGLACCPERIODBALANCES.
If we use this functional module, we will get opening and closing balance of corresponding G/L Acc.
(e.g)
CALL FUNCTION 'BAPI_GL_GETGLACCPERIODBALANCES'
EXPORTING
companycode = '1000'
glacct = '0000548101'
fiscalyear = '2007'
currencytype = '10'
IMPORTING
BALANCE_CARRIED_FORWARD = gs_bal-balance
RETURN = v_return
TABLES
account_balances = gt_bal. -
Opening Stock and Closing Stock
Hi,
I have one requirement to get a opening stock and closing stock of all materials, based on the plant date and mat type.
Could u tell me the flow of tables one by one
Its is possible to get the opening stock and closing stock of all materials.
Please Guide Me.
Thanks & Regards,
Dhanush.S.Tgo through this....
*& Report Z_OPEN_CLOSE *
REPORT Z_OPEN_CLOSE MESSAGE-ID YW2 LINE-SIZE 231 LINE-COUNT 45
NO STANDARD PAGE HEADING.
Type Declaration *
TYPE-POOLS SLIS.
Tables *
TABLES: MKPF, " Material Document: Header Data
MSEG, " Material Document: Item Data
MARA,
MARD,
S031,
EKKO,
EKPO,
LIKP,
MAKT,
J_1IWRKCUS,
T001W,
WB2_V_MKPF_MSEG2,
MMIM_REP_PRINT,
YW2_STKMOVEMENTS,
YPLNT,
MARDH.
Internal Tables *
DATA: I_WERKS LIKE J_1IWRKCUS OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF I_YPLNT OCCURS 0,
PPLNT LIKE YPLNT-PPLNT,
WPLNT LIKE YPLNT-WPLNT,
END OF I_YPLNT.
DATA: BEGIN OF I_MKPF OCCURS 0,
MBLNR LIKE MKPF-MBLNR,
MJAHR LIKE MKPF-MJAHR,
BUDAT LIKE MKPF-BUDAT,
VGART LIKE MKPF-VGART,
BWART LIKE MSEG-BWART,
MATNR LIKE MSEG-MATNR,
WERKS LIKE MSEG-WERKS,
LGORT LIKE MSEG-LGORT,
MENGE LIKE MSEG-MENGE,
MEINS LIKE MSEG-MEINS,
KUNNR LIKE MSEG-KUNNR,
ZEILE LIKE MSEG-ZEILE,
XAUTO LIKE MSEG-XAUTO,
SHKZG LIKE MSEG-SHKZG,
MATNR1 LIKE MSEG-MATNR,
END OF I_MKPF.
DATA: BEGIN OF I_MARDH OCCURS 0,
WERKS LIKE MARDH-WERKS,
MEINS LIKE MARA-MEINS,
MATNR LIKE MARDH-MATNR,
LGORT LIKE MARDH-LGORT,
LABST LIKE MARDH-LABST,
LFGJA LIKE MARDH-LFGJA, "Added -MB
LFMON LIKE MARDH-LFMON, "Added -MB
PERIO(6),
INSME LIKE MARDH-LABST,
EINME LIKE MARDH-LABST,
SPEME LIKE MARDH-LABST,
RETME LIKE MARDH-LABST,
O_STK LIKE MARDH-LABST, " Opening Stock
C_STK LIKE MARDH-LABST, " Closing Stock
END OF I_MARDH.
DATA: BEGIN OF I_MARD OCCURS 0,
WERKS LIKE MARD-WERKS,
MATNR LIKE MARD-MATNR,
LGORT LIKE MARD-LGORT,
LABST LIKE MARD-LABST,
INSME LIKE MARD-LABST,
MEINS LIKE MARA-MEINS,
EINME LIKE MARD-LABST,
SPEME LIKE MARD-LABST,
RETME LIKE MARD-LABST,
END OF I_MARD.
DATA: I_MARD1 LIKE I_MARD OCCURS 0 WITH HEADER LINE.
DATA: I_MARDH1 LIKE I_MARDH OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF I_MKPF1 OCCURS 0,
MBLNR LIKE MKPF-MBLNR,
WERKS LIKE MSEG-WERKS,
MATNR LIKE MSEG-MATNR,
BUDAT LIKE MKPF-BUDAT,
BWART LIKE MSEG-BWART,
MJAHR LIKE MKPF-MJAHR,
VGART LIKE MKPF-VGART,
LGORT LIKE MSEG-LGORT,
MENGE LIKE MSEG-MENGE,
MEINS LIKE MSEG-MEINS,
XAUTO LIKE MSEG-XAUTO,
SHKZG LIKE MSEG-SHKZG,
END OF I_MKPF1.
DATA: BEGIN OF I_MKPF2 OCCURS 0,
WERKS LIKE MSEG-WERKS,
MATNR LIKE MSEG-MATNR,
BUDAT LIKE MKPF-BUDAT,
BWART LIKE MSEG-BWART,
MJAHR LIKE MKPF-MJAHR,
VGART LIKE MKPF-VGART,
LGORT LIKE MSEG-LGORT,
MENGE LIKE MSEG-MENGE,
MEINS LIKE MSEG-MEINS,
XAUTO LIKE MSEG-XAUTO,
END OF I_MKPF2.
DATA: BEGIN OF I_FINAL5 OCCURS 0,
WERKS LIKE MSEG-WERKS, " Plant
MATNR LIKE MSEG-MATNR, " Material
LGORT LIKE MSEG-LGORT, " Storage Location
BUDAT LIKE MKPF-BUDAT, " Posting Date
MTART LIKE MARA-MTART, " Material Type
SPMON LIKE S031-SPMON, " Month
MAKTX LIKE MAKT-MAKTX, " Description
meins(3), " UOM
MEINS LIKE MSEG-MEINS,
O_STK LIKE MARDH-LABST, " opening stock
TRECEP LIKE MARDH-LABST, " total receipts
PRODU LIKE MARDH-LABST, " Net Receipts - Production
RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
TDISP LIKE MARDH-LABST, " total dispatches
CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
TLOSS LIKE MARDH-LABST, " Total Loss
TRLOSS LIKE MARDH-LABST, " Transit Loss
WHLOSS LIKE MARDH-LABST, " Warehouse Loss
C_STK LIKE MARDH-LABST, " Closing Stock
TRFSTK LIKE MARDH-LABST, "Transfer stock
MENGE LIKE MSEG-MENGE,
OTHADJ LIKE MARDH-LABST,
END OF I_FINAL5.
DATA: BEGIN OF I_FINAL OCCURS 0,
WERKS LIKE MSEG-WERKS, " Plant
MATNR LIKE MSEG-MATNR, " Material
BUDAT LIKE MKPF-BUDAT, " Posting Date
MTART LIKE MARA-MTART, " Material Type
SPMON LIKE S031-SPMON, " Month
MAKTX LIKE MAKT-MAKTX, " Description
meins(3), " UOM
MEINS LIKE MSEG-MEINS,
O_STK LIKE MARDH-LABST, " opening stock
TRECEP LIKE MARDH-LABST, " total receipts
PRODU LIKE MARDH-LABST, " Net Receipts - Production
RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
TDISP LIKE MARDH-LABST, " total dispatches
CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
TRFSTK LIKE MARDH-LABST, "Material Transfer stock
TRLOSS LIKE MARDH-LABST, " Transit Loss
WHLOSS LIKE MARDH-LABST, " Warehouse Loss
TLOSS LIKE MARDH-LABST, " Total Loss
C_STK LIKE MARDH-LABST, " Closing Stock
OTHADJ LIKE MARDH-LABST,
END OF I_FINAL.
DATA: I_FINAL1 LIKE I_FINAL OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF I_FINAL_TEMP OCCURS 0,
WERKS LIKE MSEG-WERKS, " Plant
MATNR LIKE MSEG-MATNR, " Material
MTART LIKE MARA-MTART, " Material Type
MAKTX LIKE MAKT-MAKTX, " Description
MEINS LIKE MSEG-MEINS,
O_STK LIKE MARDH-LABST, " opening stock
TRECEP LIKE MARDH-LABST, " total receipts
PRODU LIKE MARDH-LABST, " Net Receipts - Production
RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
TDISP LIKE MARDH-LABST, " total dispatches
CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
TRFSTK LIKE MARDH-LABST, "Material Transfer stock
TRLOSS LIKE MARDH-LABST, " Transit Loss
WHLOSS LIKE MARDH-LABST, " Warehouse Loss
TLOSS LIKE MARDH-LABST, " Total Loss
C_STK LIKE MARDH-LABST, " Closing Stock
OTHADJ LIKE MARDH-LABST,
END OF I_FINAL_TEMP.
For Materials
DATA: BEGIN OF I_MARA OCCURS 0,
MATNR TYPE MARA-MATNR,
MTART TYPE MARA-MTART,
MEINS LIKE MARA-MEINS,
LABST TYPE MARD-LABST,
MAKTX LIKE MAKT-MAKTX,
END OF I_MARA.
DATA: BEGIN OF I_STKMVMNTS OCCURS 0,
BWART LIKE MSEG-BWART,
SHKZG LIKE MSEG-SHKZG,
VZBEW LIKE YW2_STKMOVEMENTS-VZBEW,
END OF I_STKMVMNTS.
DATA: BEGIN OF I_FINALT OCCURS 0,
WERKS LIKE MSEG-WERKS, " Plant
MATNR LIKE MSEG-MATNR, " Material
BUDAT LIKE MKPF-BUDAT, " Posting Date
MTART LIKE MARA-MTART, " Material Type
SPMON LIKE S031-SPMON, " Month
MAKTX LIKE MAKT-MAKTX, " Description
meins(3), " UOM
MEINS LIKE MSEG-MEINS,
O_STK LIKE MARDH-LABST, " opening stock
TRECEP LIKE MARDH-LABST, " total receipts
PRODU LIKE MARDH-LABST, " Net Receipts - Production
RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
TDISP LIKE MARDH-LABST, " total dispatches
CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
TRFSTK LIKE MARDH-LABST, "Material Transfer stock
TRLOSS LIKE MARDH-LABST, " Transit Loss
WHLOSS LIKE MARDH-LABST, " Warehouse Loss
TLOSS LIKE MARDH-LABST, " Total Loss
C_STK LIKE MARDH-LABST, " Closing Stock
OTHADJ LIKE MARDH-LABST,
MONTH(8) ,
END OF I_FINALT.
DATA: IMKPFT LIKE I_MKPF OCCURS 0 WITH HEADER LINE.
DATA: IMKPFT1 LIKE I_MKPF1 OCCURS 0 WITH HEADER LINE.
DATA: IMARDT LIKE I_MARD OCCURS 0 WITH HEADER LINE.
DATA: IMARDHT LIKE I_MARDH OCCURS 0 WITH HEADER LINE.
DATA: T_FINAL LIKE I_MKPF OCCURS 0 WITH HEADER LINE.
DATA: IMKPFT2 LIKE I_MKPF OCCURS 0 WITH HEADER LINE.
FCAT is used for the field catalog
DATA: FCAT TYPE TABLE OF SLIS_FIELDCAT_ALV WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
for excluding the ICONs from the application toolbar
FEXC TYPE TABLE OF SLIS_EXTAB WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
FS_LAYO is used for Grid Layout
FS_LAYO TYPE SLIS_LAYOUT_ALV,
FEVENTS to handle the events TOP OF PAGE & USER_COMMAND
FEVENTS TYPE TABLE OF SLIS_ALV_EVENT WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
FHEADER is used for List header
FHEADER TYPE TABLE OF SLIS_LISTHEADER WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
sort is used for sorting
FSORT TYPE TABLE OF SLIS_SORTINFO_ALV WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
FCAT1 TYPE TABLE OF SLIS_FIELDCAT_ALV WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
FS_LAYO1 TYPE SLIS_LAYOUT_ALV,
GT_LIST_TOP_OF_PAGE1 TYPE SLIS_T_LISTHEADER,
FEVENTS1 TYPE TABLE OF SLIS_ALV_EVENT WITH NON-UNIQUE DEFAULT KEY
WITH HEADER LINE INITIAL SIZE 0,
FHEADER1 TYPE TABLE OF SLIS_LISTHEADER WITH NON-UNIQUE DEFAULT
KEY WITH HEADER LINE INITIAL SIZE 0,
G_STATU_071 TYPE SLIS_FORMNAME VALUE 'Z_PFSTATUS',
ALV_VARIANT1 LIKE DISVARIANT.
Variable Declaration *
TYPES: TRFF_TYPE_DEC_6_5(6) TYPE P DECIMALS 5.
DATA: FYEAR(4),
MON(2),
FYEAR1(4),
MON1(2),
OBAL LIKE MARD-LABST,
CBAL LIKE MARD-LABST,
INDEX TYPE I,
COUNT,
COUNT1 TYPE I,
O_STK TYPE P DECIMALS 3,
C_STK TYPE P DECIMALS 3,
V_MJAHR LIKE MKPF-MJAHR,
MONTHS TYPE TRFF_TYPE_DEC_6_5,
MONTH TYPE I.
Global variables for handling ALV functionality
DATA: ALV_KEYINFO TYPE SLIS_KEYINFO_ALV,
ALV_VARIANT LIKE DISVARIANT,
ALV_LAYOUT TYPE SLIS_LAYOUT_ALV,
ALV_REPID LIKE SY-REPID,
ALV_PRINT TYPE SLIS_PRINT_ALV,
ALV_DETAIL_FUNC(30),
ALV_DEFAULT_VARIANT LIKE DISVARIANT-VARIANT,
ALV_COLOURIZE_FIELDS LIKE MMIM_REP_PRINT-COLOR.
RANGES: R_BUDAT FOR MKPF-BUDAT.
*Added by Prabhu for year on 26.4.05.
DATA: IDATE LIKE R_BUDAT OCCURS 0 WITH HEADER LINE.
Selection Screen Elements *
SELECTION-SCREEN BEGIN OF BLOCK BLK WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_WERKS FOR MARD-WERKS OBLIGATORY NO INTERVALS.
PARAMETER: P_SPMON LIKE S031-SPMON NO-DISPLAY .
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR OBLIGATORY,
S_LGORT FOR MSEG-LGORT NO-EXTENSION NO INTERVALS,
S_MBLNR FOR MKPF-MBLNR,
S_BUDAT FOR MKPF-BUDAT OBLIGATORY .
SELECTION-SCREEN END OF BLOCK BLK.
SELECTION-SCREEN BEGIN OF BLOCK BLK3 WITH FRAME TITLE TEXT-004.
PARAMETER : MTART LIKE MARA-MTART DEFAULT 'FERT' NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK BLK3.
SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-003.
SELECTION-SCREEN END OF BLOCK BLK2.
ADDED BY PRABHU FOR DAY-WISE REPORT.
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-007.
PARAMETERS: D1 RADIOBUTTON GROUP P1 DEFAULT 'X',
M1 RADIOBUTTON GROUP P1,
Y1 RADIOBUTTON GROUP P1.
SELECTION-SCREEN END OF BLOCK B3.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-006.
PARAMETERS: ALV_DEF LIKE DISVARIANT-VARIANT.
SELECTION-SCREEN END OF BLOCK B2.
DATA: S_BUDAT1 LIKE S_BUDAT OCCURS 0 WITH HEADER LINE."prabhu
Initialization *
INITIALIZATION.
PERFORM ALV_INIT.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR ALV_DEF.
PERFORM ALV_F4.
At Selection Screen
*AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_spmon.
PERFORM monat_f4.
At Selection Screen *
AT SELECTION-SCREEN.
checking for the layout
PERFORM ALV_CHECK.
authorisation check for the Plant
PERFORM auth_check.
Validation for the Plant
PERFORM VALIDITY_CHECK.
IF MTART NE 'FERT'.
MESSAGE E041 WITH 'Material Type must be FERT Only...'.
ENDIF.
IF D1 = 'X'." On 26.4.05.
P_SPMON0(4) = S_BUDAT-LOW0(4).
P_SPMON4(2) = S_BUDAT-LOW4(2).
ELSE.
P_SPMON0(4) = S_BUDAT-LOW0(4).
P_SPMON4(2) = S_BUDAT-LOW4(2).
ENDIF.
LOOP AT S_BUDAT.
IF S_BUDAT-HIGH IS INITIAL.
S_BUDAT-HIGH = S_BUDAT-LOW.
MODIFY S_BUDAT.
ENDIF.
ENDLOOP.
IDATE-LOW = S_BUDAT-LOW.
IDATE-HIGH = S_BUDAT-HIGH.
CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
EXPORTING
I_DATE_FROM = IDATE-LOW
I_DATE_TO = IDATE-HIGH
IMPORTING
E_DAYS =
E_MONTHS = MONTH
E_YEARS =
DATA: I(3) TYPE C.
I = S_BUDAT-LOW+4(2).
CLEAR: R_BUDAT.
REFRESH: R_BUDAT.
*added by Prabhu for Only for Oneday.on 18.5.5
IF MONTH EQ '0'.
MONTH = MONTH + 1.
ENDIF.
*added by Prabhu for Only for Oneday.on 18.5.5
DO MONTH TIMES.
R_BUDAT-LOW = S_BUDAT-LOW.
APPEND R_BUDAT.
ENDDO.
I = 0.
LOOP AT R_BUDAT.
R_BUDAT-LOW4(2) = S_BUDAT-LOW4(2) + I.
I = I + 1.
R_BUDAT-LOW+6(2) = '01'.
MODIFY R_BUDAT.
ENDLOOP.
LOOP AT R_BUDAT.
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
DAY_IN = R_BUDAT-LOW
IMPORTING
LAST_DAY_OF_MONTH = R_BUDAT-HIGH
EXCEPTIONS
DAY_IN_NO_DATE = 1
OTHERS = 2
MODIFY R_BUDAT.
ENDLOOP.
LOOP AT R_BUDAT.
IF R_BUDAT-LOW4(2) = S_BUDAT-LOW4(2).
R_BUDAT-LOW = S_BUDAT-LOW.
MODIFY R_BUDAT.
ENDIF.
IF R_BUDAT-HIGH4(2) = S_BUDAT-HIGH4(2).
R_BUDAT-HIGH = S_BUDAT-HIGH.
MODIFY R_BUDAT.
ENDIF.
For Summary on 26.4.05.
IF Y1 = 'X'.
CLEAR R_BUDAT.
REFRESH R_BUDAT.
R_BUDAT-LOW = S_BUDAT-LOW.
R_BUDAT-HIGH = S_BUDAT-HIGH.
APPEND R_BUDAT.
CLEAR R_BUDAT.
ENDIF.
ENDLOOP.
At Selection Screen *
AT SELECTION-SCREEN OUTPUT.
Start of Selection *
START-OF-SELECTION.
V_MJAHR = P_SPMON+0(4).
Get plant distinction warehouse/production
PERFORM GET_PLANT_DISTINCTION.
Collect the data from various tables
PERFORM GETDATA_FG_STOCK.
here the number of rows in the output table is found
PERFORM OUTPUT_TABLE_CHECK.
here the top of the page code is written, that is to be displayed
in the output
PERFORM Z_TOP_OF_PAGE.
here ALV layout properties are set
PERFORM Z_LAYOUT_SETTINGS.
ALV EVENTS for TOP OF PAGE and for USER COMMAND
PERFORM Z_ALV_EVENTS.
The field catalog is defined for the Primary List is defined in
the subroutine CREATE_FIELD_CATALOG include program ZPRRDOCR_FCAT
PERFORM Z_CREATE_FIELD_CATALOG.
This is for displaying the output
PERFORM Z_REUSE_ALV_GRID_DISPLAY.
*& Form getdata_fg_stock
Getting data from standard tables
FORM GETDATA_FG_STOCK.
For getting the Start date & end date of the month
PERFORM get_month_dates.
Getting the Opening Stock from MARDH table
IF MON EQ '01'.
MON1 = MON.
FYEAR1 = FYEAR.
MON = '12'.
FYEAR = FYEAR - 1.
ELSE.
MON1 = MON.
FYEAR1 = FYEAR.
MON = MON - 1.
FYEAR = FYEAR.
ENDIF.
PERFORM GET_RECORDS_FROM_DB.
*added for Month Summary on 26.4.05.
LOOP AT R_BUDAT.
S_BUDAT-LOW = R_BUDAT-LOW.
S_BUDAT-HIGH = R_BUDAT-HIGH.
*for Month
P_SPMON0(4) = S_BUDAT-LOW0(4).
P_SPMON4(2) = S_BUDAT-LOW4(2).
*for summary.
IF Y1 = 'X'.
LOOP AT S_BUDAT.
S_BUDAT1-SIGN = 'I'.
S_BUDAT1-OPTION = 'NB'.
S_BUDAT1-LOW = S_BUDAT-LOW.
S_BUDAT1-HIGH = S_BUDAT-HIGH.
APPEND S_BUDAT1.
CLEAR S_BUDAT1.
ENDLOOP.
ENDIF.
IMKPFT[] = I_MKPF[].
IMKPFT2[] = I_MKPF[].
IMARDT[] = I_MARD[].
IMARDHT[] = I_MARDH[].
PERFORM MONTH_WISE.
PERFORM PROCESS_MOVEMENTS.
PERFORM CALCULATE_OPENING_STOCK.
PERFORM UPDATE_NON_TRANSACTION_ITMS.
PERFORM DELETE_EMPTY_RECORDS.
CLEAR: IMARDHT,IMARDT,IMKPFT1,IMKPFT,I_FINAL,I_FINAL5.
REFRESH: IMARDHT,IMARDT,IMKPFT1,I_FINAL,I_FINAL5,IMKPFT.
ENDLOOP.
CLEAR: R_BUDAT.
REFRESH: R_BUDAT.
*end of changes for month.
ENDFORM. " getdata_fg_stock
FORM MONAT_F4 *
F4-Hilfe für Monat *
FORM MONAT_F4.
DATA: BEGIN OF MF_DYNPFIELDS OCCURS 1.
INCLUDE STRUCTURE DYNPREAD.
DATA: END OF MF_DYNPFIELDS.
DATA: MF_RETURNCODE LIKE SY-SUBRC,
MF_MONAT LIKE ISELLIST-MONTH,
MF_HLP_REPID LIKE SY-REPID.
FIELD-SYMBOLS: .
Wert von Dynpro lesen
GET CURSOR FIELD MF_DYNPFIELDS-FIELDNAME.
APPEND MF_DYNPFIELDS.
MF_HLP_REPID = SY-REPID.
DO 2 TIMES.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = MF_HLP_REPID
DYNUMB = SY-DYNNR
TABLES
DYNPFIELDS = MF_DYNPFIELDS
EXCEPTIONS
INVALID_ABAPWORKAREA = 01
INVALID_DYNPROFIELD = 02
INVALID_DYNPRONAME = 03
INVALID_DYNPRONUMMER = 04
INVALID_REQUEST = 05
NO_FIELDDESCRIPTION = 06
UNDEFIND_ERROR = 07.
IF SY-SUBRC = 3.
Aktuelles Dynpro ist Wertemengenbild
MF_HLP_REPID = 'SAPLALDB'.
ELSE.
READ TABLE MF_DYNPFIELDS INDEX 1.
Unterstriche durch Blanks ersetzen
TRANSLATE MF_DYNPFIELDS-FIELDVALUE USING '_ '.
EXIT.
ENDIF.
ENDDO.
IF SY-SUBRC = 0.
Konvertierung ins interne Format
CALL FUNCTION 'CONVERSION_EXIT_PERI_INPUT'
EXPORTING
INPUT = MF_DYNPFIELDS-FIELDVALUE
IMPORTING
OUTPUT = MF_MONAT
EXCEPTIONS
ERROR_MESSAGE = 1.
IF MF_MONAT IS INITIAL.
Monat ist initial => Vorschlagswert aus akt. Datum ableiten
MF_MONAT = SY-DATLO(6).
ENDIF.
CALL FUNCTION 'POPUP_TO_SELECT_MONTH'
EXPORTING
ACTUAL_MONTH = MF_MONAT
IMPORTING
SELECTED_MONTH = MF_MONAT
RETURN_CODE = MF_RETURNCODE
EXCEPTIONS
FACTORY_CALENDAR_NOT_FOUND = 01
HOLIDAY_CALENDAR_NOT_FOUND = 02
MONTH_NOT_FOUND = 03.
IF SY-SUBRC = 0 AND MF_RETURNCODE = 0.
ASSIGN (MF_DYNPFIELDS-FIELDNAME) TO <MF_FELD>. " ==>> note 148804
<MF_FELD> = MF_MONAT.
CALL FUNCTION 'CONVERSION_EXIT_PERI_OUTPUT'
EXPORTING
INPUT = MF_MONAT
IMPORTING
OUTPUT = MF_DYNPFIELDS-FIELDVALUE.
COLLECT MF_DYNPFIELDS.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
DYNAME = MF_HLP_REPID
DYNUMB = SY-DYNNR
TABLES
DYNPFIELDS = MF_DYNPFIELDS
EXCEPTIONS
INVALID_ABAPWORKAREA = 01
INVALID_DYNPROFIELD = 02
INVALID_DYNPRONAME = 03
INVALID_DYNPRONUMMER = 04
INVALID_REQUEST = 05
NO_FIELDDESCRIPTION = 06
UNDEFIND_ERROR = 07. "<<== note 148804
ENDIF.
ENDIF.
ENDFORM. "MONAT_F4
*& Form get_month_dates
Calculating the Month Start & End Date
FORM GET_MONTH_DATES.
IF M1 = 'X'.
FYEAR = P_SPMON+0(4).
MON = P_SPMON+4(2).
CONCATENATE FYEAR MON '01' INTO R_BUDAT-LOW.
R_BUDAT-SIGN = 'I'.
R_BUDAT-OPTION = 'BT'.
CALL FUNCTION 'BKK_GET_MONTH_LASTDAY'
EXPORTING
I_DATE = R_BUDAT-LOW
IMPORTING
E_DATE = R_BUDAT-HIGH.
APPEND R_BUDAT.
CLEAR S_BUDAT.
REFRESH S_BUDAT.
S_BUDAT-SIGN = 'I'.
S_BUDAT-OPTION = 'BT'.
S_BUDAT-LOW = R_BUDAT-LOW.
S_BUDAT-HIGH = R_BUDAT-HIGH.
APPEND S_BUDAT.
ELSE.
FYEAR = P_SPMON+0(4).
MON = P_SPMON+4(2).
CONCATENATE FYEAR MON '01' INTO R_BUDAT-LOW.
R_BUDAT-SIGN = 'I'.
R_BUDAT-OPTION = 'BT'.
CALL FUNCTION 'BKK_GET_MONTH_LASTDAY'
EXPORTING
I_DATE = R_BUDAT-LOW
IMPORTING
E_DATE = R_BUDAT-HIGH.
APPEND R_BUDAT.
ENDIF.
ENDFORM. " get_month_dates
*& Form output_table_Check
checking for records for output
FORM OUTPUT_TABLE_CHECK .
DESCRIBE TABLE I_FINALT LINES INDEX.
IF INDEX EQ 0.
MESSAGE I041 WITH TEXT-005.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. "OUTPUT_TABLE_CHECK
*& Form Z_TOP_OF_PAGE
for setting the details in the top of page *
has no formal paramters *
FORM Z_TOP_OF_PAGE.
DATA: V_MON(2),
V_YR(40),
V_FIN(18),
V_FIN1(48),
LOW(10),
HIGH(10).
V_MON = P_SPMON+4(2).
V_YR = P_SPMON+0(4).
FHEADER-TYP = 'H'.
FHEADER-INFO = 'Stock Register Report (FG Stock)'.
APPEND FHEADER.
CLEAR FHEADER.
*if m1 = 'X'.
CONCATENATE 'Month = ' v_mon '.' v_yr INTO v_fin.
fheader-typ = 'H'.
fheader-info = v_fin.
APPEND fheader.
CLEAR fheader.
*endif."prabhu on 18.5.5
IF D1 = 'X'.
CLEAR S_BUDAT.
LOOP AT S_BUDAT.
CONCATENATE S_BUDAT-LOW6(2) '/' S_BUDAT-LOW4(2) '/'
S_BUDAT-LOW+0(4) INTO LOW.
CONCATENATE S_BUDAT-HIGH6(2) '/' S_BUDAT-HIGH4(2) '/'
S_BUDAT-HIGH+0(4) INTO HIGH.
CONCATENATE 'Date = ' LOW ' - ' HIGH INTO V_FIN1.
FHEADER-TYP = 'H'.
FHEADER-INFO = V_FIN1.
APPEND FHEADER.
CLEAR FHEADER.
ENDLOOP.
ENDIF.
ENDFORM. " Z_TOP_OF_PAGE
*& Form Z_LAYOUT_SETTINGS
this is done for setting the properties for the layout of the *
grid *
has no formal paramters *
FORM Z_LAYOUT_SETTINGS.
FS_LAYO-ZEBRA = 'X'. " Output in Zebra pattern
FS_LAYO-DETAIL_POPUP = 'X'. " A popup window appears to give
FS_LAYO-DETAIL_TITLEBAR = TEXT-022.
FS_LAYO-COLWIDTH_OPTIMIZE = 'X'.
ENDFORM. " Z_LAYOUT_SETTINGS
*& Form Z_ALV_EVENTS
This is used for handling the events TOP OF PAGE and the USER *
COMMAND event *
has no formal paramters *
FORM Z_ALV_EVENTS.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = FEVENTS[].
READ TABLE FEVENTS WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC = 0.
FEVENTS-FORM = 'Z_TOPOFPAGE'.
MODIFY FEVENTS INDEX SY-TABIX.
CLEAR FEVENTS.
ENDIF.
READ TABLE FEVENTS WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC = 0.
FEVENTS-FORM = 'Z_USER_COMMAND'.
MODIFY FEVENTS INDEX SY-TABIX.
CLEAR FEVENTS.
ENDIF.
ENDFORM. "Z_ALV_EVENTS
*& Form Z_CREATE_FIELD_CATALOG
here the field catalog is created for the primary list *
no formal parameters *
FORM Z_CREATE_FIELD_CATALOG.
for the Plant
FCAT-FIELDNAME = 'WERKS'.
FCAT-KEY = 'X'.
FCAT-OUTPUTLEN = '000005'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Plant'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'CHAR'.
APPEND FCAT.
CLEAR FCAT.
for the Material Type
FCAT-FIELDNAME = 'MTART'.
FCAT-KEY = 'X'.
FCAT-OUTPUTLEN = '000006'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'MatTyp'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'CHAR'.
APPEND FCAT.
CLEAR FCAT.
for the Material No.
FCAT-FIELDNAME = 'MATNR'.
FCAT-KEY = 'X'.
fcat-hotspot = 'X'.
FCAT-OUTPUTLEN = '000018'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Material'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'CHAR'.
APPEND FCAT.
CLEAR FCAT.
for the Material Description
FCAT-FIELDNAME = 'MAKTX'.
FCAT-KEY = ''.
FCAT-OUTPUTLEN = '000040'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Description'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'CHAR'.
APPEND FCAT.
CLEAR FCAT.
for the Unit of Measure
FCAT-FIELDNAME = 'MEINS'.
FCAT-KEY = ''.
FCAT-OUTPUTLEN = '03'.
FCAT-JUST = 'C'.
FCAT-SELTEXT_M = 'UOM'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'UNIT'.
APPEND FCAT.
CLEAR FCAT.
for the Plant
FCAT-FIELDNAME = 'MONTH'.
FCAT-KEY = 'X'.
FCAT-OUTPUTLEN = '08'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'MONTH'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'C'.
FCAT-DATATYPE = 'CHAR'.
APPEND FCAT.
CLEAR FCAT.
for the Opening Stock
FCAT-FIELDNAME = 'C_STK'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Opening Stock'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
fcat-do_sum = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT.
for the Total Receipts
FCAT-FIELDNAME = 'TRECEP'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Total Receipts'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
FCAT-DO_SUM = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT.
for the Production
FCAT-FIELDNAME = 'PRODU'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Production'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
FCAT-DO_SUM = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT.
for the Other Plant Receipts
FCAT-FIELDNAME = 'RECEP'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Othr Plnt Recpts'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
FCAT-DO_SUM = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT.
Sales Return
FCAT-FIELDNAME = 'SAL_RET'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Sales Return'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
FCAT-DO_SUM = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT.
Total Dispatches
FCAT-FIELDNAME = 'TDISP'.
FCAT-HOTSPOT = ' '.
FCAT-OUTPUTLEN = '000016'.
FCAT-JUST = 'L'.
FCAT-SELTEXT_M = 'Total Dispatches'.
FCAT-DDICTXT = 'M'.
FCAT-INTTYPE = 'Q'.
FCAT-DATATYPE = 'QUAN'.
FCAT-DO_SUM = 'X'.
FCAT-JUST = 'R'.
FCAT-NO_ZERO = 'X'.
APPEND FCAT.
CLEAR FCAT. -
Opening Stock and Closing Stock fields and Calculation
Hi,
My report requirement is to display the material, opening stock for the lower date, closing stock for the higher date and the in between all stock operations..how to fetch the opening stock and closing stock for a particular material ???.. what are the tables and fields for calculating them??..
Thanks,
Srithis is the code i wrote..
I had selected the data for the date entered and the previous date(l_date) also..
previous date for the opening stock.
now i am getting only receipts and issues correctly.. opening stock and the remaining
balance fields are not coming properly..please help me..
here rmenge for receipts,imenge for issues.
REPORT ZSTOCK no standard page heading line-size 180.
types: begin of ty_date,
budat type budat,
end of ty_date,
begin of ty_mard,
matnr type matnr,
lgort type lgort_d,
labst type labst,
UMLME TYPE UMLMD,
INSME TYPE INSME,
EINME TYPE EINME,
SPEME TYPE SPEME,
RETME TYPE RETME,
end of ty_mard,
begin of ty_makt,
matnr type matnr,
maktx type maktx,
end of ty_makt,
begin of ty_mbew,
matnr type matnr,
bwkey type bwkey,
lbkum type lbkum,
salk3 type salk3,
end of ty_mbew,
begin of ty_mkpfmseg,
mblnr type mblnr,
budat type budat,
bwart type bwart,
matnr type matnr,
lgort type lgort_d,
shkzg type shkzg,
dmbtr type dmbtr,
menge type mseg-menge,
end of ty_mkpfmseg,
begin of ty_opstock,
matnr type matnr,
rdmbtr type dmbtr,
idmbtr type dmbtr,
bdmbtr type dmbtr,
bmenge type menge_d,
end of ty_opstock,
begin of ty_output,
mblnr type mblnr,
budat type budat,
matnr type matnr,
maktx type maktx,
bwart type bwart,
lgort type lgort_d,
shkzg type shkzg,
rmenge type mseg-menge,
rdmbtr type dmbtr,
imenge type mseg-menge,
idmbtr type dmbtr,
dmbtr type dmbtr,
bdmbtr type dmbtr,
bmenge type menge_d,
end of ty_output.
data: t_date type standard table of ty_date initial size 0,
t_mard type standard table of ty_mard initial size 0,
t_makt type standard table of ty_makt initial size 0,
t_mkpfmseg type standard table of ty_mkpfmseg initial size 0,
t_opstock type standard table of ty_opstock initial size 0,
t_out type standard table of ty_output initial size 0,
w_date type ty_date,
w_mard type ty_mard,
w_makt type ty_makt,
w_mkpfmseg type ty_mkpfmseg,
w_opstock type ty_opstock,
w_out type ty_output,
g_matnr type mara-matnr,
g_lgort type t001l-lgort.
selection-screen begin of block b1 with frame.
parameters:p_werks type t001l-werks obligatory memory id pw.
select-options:s_lgort for g_lgort no-extension no intervals.
select-options: s_matnr for g_matnr.
parameters:p_date type mkpf-budat obligatory.
selection-screen end of block b1.
at selection-screen.
perform sub_validate_date.
start-of-selection.
data: l_date type sy-datum,
l_row type i.
refresh t_date.
select budat from mkpf into table t_date.
sort t_date.
delete adjacent duplicates from t_date.
clear w_date.
read table t_date into w_date with key budat = p_date.
l_row = sy-tabix.
l_row = l_row - 1.
clear w_date.
read table t_date into w_date index l_row.
l_date = w_date-budat.
select k~mblnr
k~budat
s~bwart
s~matnr
s~lgort
s~shkzg
s~dmbtr
s~menge
into table t_mkpfmseg
from mkpf as k inner join mseg as s
on kmblnr = smblnr and
kmjahr = smjahr
where k~budat between l_date and p_date and
s~matnr in s_matnr and
s~werks = p_werks and
s~lgort in s_lgort.
if t_mkpfmseg is not initial.
sort t_mkpfmseg by budat ascending
matnr ascending.
select matnr
lgort
labst
umlme
insme
einme
speme
retme
from mard
into table t_mard
for all entries in t_mkpfmseg
where matnr = t_mkpfmseg-matnr and
werks = p_werks and
lgort in s_lgort.
select matnr
maktx
from makt
into table t_makt
for all entries in t_mkpfmseg
where matnr = t_mkpfmseg-matnr.
endif.
loop at t_mkpfmseg into w_mkpfmseg where budat = l_date.
loop at t_mard into w_mard where matnr = w_mkpfmseg-matnr.
w_opstock-matnr = w_mkpfmseg-matnr.
if w_mkpfmseg-shkzg = 'S'. " Receive
w_opstock-rdmbtr = w_mkpfmseg-dmbtr.
w_opstock-bmenge = w_mard-labst + w_mard-insme + w_mard-speme
+ w_mard-einme + w_mard-retme
- w_mkpfmseg-menge.
elseif w_mkpfmseg-shkzg = 'H'. " Issue
w_opstock-idmbtr = w_mkpfmseg-dmbtr.
w_opstock-bmenge = w_out-bmenge + w_mkpfmseg-menge.
endif.
w_opstock-bdmbtr = w_out-rdmbtr - w_out-idmbtr.
append w_opstock to t_opstock.
clear w_opstock.
endloop.
endloop.
loop at t_mkpfmseg into w_mkpfmseg where budat = p_date.
loop at t_mard into w_mard where matnr = w_mkpfmseg-matnr.
clear w_makt.
read table t_makt into w_makt with key matnr = w_mkpfmseg-matnr.
if sy-subrc = 0.
w_out-budat = w_mkpfmseg-budat.
w_out-matnr = w_mard-matnr.
w_out-maktx = w_makt-maktx.
w_out-lgort = w_mard-lgort.
w_out-mblnr = w_mkpfmseg-mblnr.
w_out-bwart = w_mkpfmseg-bwart.
w_out-shkzg = w_mkpfmseg-shkzg.
if w_mkpfmseg-shkzg = 'S'. " Receive
w_out-rmenge = w_mkpfmseg-menge.
w_out-rdmbtr = w_mkpfmseg-dmbtr.
w_out-imenge = 0.
w_out-bmenge = w_mard-labst + w_mard-insme + w_mard-speme
+ w_mard-einme + w_mard-retme
- w_mkpfmseg-menge.
elseif w_mkpfmseg-shkzg = 'H'. " Issue
w_out-imenge = w_mkpfmseg-menge.
w_out-idmbtr = w_mkpfmseg-dmbtr.
w_out-rmenge = 0.
w_out-bmenge = w_out-bmenge + w_mkpfmseg-menge.
endif.
w_out-bdmbtr = w_out-rdmbtr - w_out-idmbtr.
append w_out to t_out.
clear w_out.
endif.
endloop.
endloop.
write: / 'Material' , 12 'Description' ,40 'Location', 50 'Opening stock',70 'MvT',
83 'Receipts' , 102 'Issues', 118 'Amount',135 'Balance Quan', 155 'Balance Amount'.
loop at t_out into w_out.
write: / w_out-matnr, 12 w_out-maktx, 40 w_out-lgort.
clear w_opstock.
read table t_opstock into w_opstock with key matnr = w_out-matnr.
if sy-subrc = 0.
write: 45 w_out-bmenge.
endif.
write: 70 w_out-bwart,75 w_out-rmenge,92 w_out-imenge,
110 w_out-bdmbtr, 130 w_out-bmenge, 150 w_out-bdmbtr.
endloop.
*& Form SUB_VALIDATE_DATE
FORM SUB_VALIDATE_DATE.
select budat
from mkpf
into table t_date
where budat = p_date.
if t_date is initial.
message e001(zks) with 'select another date range'.
endif.
ENDFORM. " SUB_VALIDATE_DATE
Edited by: Sri on Feb 18, 2009 8:31 AM -
Performance Degradation - High fetches and Prses
Hello,
My analysis on a particular job trace file drew my attention towards:
1) High rate of Parses instead of Bind variables usage.
2) High fetches and poor number/ low number of rows being processed
Please let me kno as to how the performance degradation can be minimised, Perhaps the high number of SQL* Net Client wait events may be due to multiple fetches and transactions with the client.
EXPLAIN PLAN FOR SELECT /*+ FIRST_ROWS (1) */ * FROM SAPNXP.INOB
WHERE MANDT = :A0
AND KLART = :A1
AND OBTAB = :A2
AND OBJEK LIKE :A3 AND ROWNUM <= :A4;
call count cpu elapsed disk query current rows
Parse 119 0.00 0.00 0 0 0 0
Execute 239 0.16 0.13 0 0 0 0
Fetch 239 2069.31 2127.88 0 13738804 0 0
total 597 2069.47 2128.01 0 13738804 0 0
PLAN_TABLE_OUTPUT
Plan hash value: 1235313998
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 2 | 268 | 1 (0)| 00:00:01 |
|* 1 | COUNT STOPKEY | | | | | |
|* 2 | TABLE ACCESS BY INDEX ROWID| INOB | 2 | 268 | 1 (0)| 00:00:01 |
|* 3 | INDEX SKIP SCAN | INOB~2 | 7514 | | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter(ROWNUM<=TO_NUMBER(:A4))
2 - filter("OBJEK" LIKE :A3 AND "KLART"=:A1)
3 - access("MANDT"=:A0 AND "OBTAB"=:A2)
filter("OBTAB"=:A2)
18 rows selected.
SQL> SELECT INDEX_NAME,TABLE_NAME,COLUMN_NAME FROM DBA_IND_COLUMNS WHERE INDEX_OWNER='SAPNXP' AND INDEX_NAME='INOB~2';
INDEX_NAME TABLE_NAME COLUMN_NAME
INOB~2 INOB MANDT
INOB~2 INOB CLINT
INOB~2 INOB OBTAB
Is it possible to Maximise the rows/fetch
call count cpu elapsed disk query current rows
Parse 163 0.03 0.00 0 0 0 0
Execute 163 0.01 0.03 0 0 0 0
Fetch 174899 55.26 59.14 0 1387649 0 4718932
total 175225 55.30 59.19 0 1387649 0 4718932
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 27
Rows Row Source Operation
28952 TABLE ACCESS BY INDEX ROWID EDIDC (cr=8505 pr=0 pw=0 time=202797 us)
28952 INDEX RANGE SCAN EDIDC~1 (cr=1457 pr=0 pw=0 time=29112 us)(object id 202995)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 174899 0.00 0.16
SQL*Net more data to client 155767 0.01 5.69
SQL*Net message from client 174899 0.11 208.21
latch: cache buffers chains 2 0.00 0.00
latch free 4 0.00 0.00
********************************************************************************user4566776 wrote:
My analysis on a particular job trace file drew my attention towards:
1) High rate of Parses instead of Bind variables usage.
But if you look at the text you are using bind variables.
The first query is executed 239 times - which matches the 239 fetches. You cut off some of the useful information from the tkprof output, but the figures show that you're executing more than once per parse call. The time is CPU time spent using a bad execution plan to find no data -- this looks like a bad choice of index, possibly a side effect of the first_rows(1) hint.
2) High fetches and poor number/ low number of rows being processedThe second query is doing a lot of fetches because in 163 executions it is fetching 4.7 million rows at roughly 25 rows per fetch. You might improve performance a little by increasing the array fetch size - but probably not by more than a factor of 2.
You'll notice that even though you record 163 parse calls for the second statement the number of " Misses in library cache during parse" is zero - so the parse calls are pretty irrelevant, the cursor is being re-used.
Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com
http://www.jlcomp.demon.co.uk
To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.
"Science is more than a body of knowledge; it is a way of thinking"
Carl Sagan -
Hi
how to findout open stock for the date and closing stock .hi
good
DATA : it_mard LIKE mard OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF t_mard OCCURS 0 ,
matnr LIKE mseg-matnr,
labst LIKE mard-labst,
END OF t_mard.
DATA : it_mardh TYPE mardh.
DATA : buper LIKE t009b-poper,
gjahr LIKE t009b-bdatj.
DATA : p_buper LIKE t009b-poper,
p_gjahr LIKE t009b-bdatj.
DATA : dt LIKE sy-datum.
*CLOSING STOCK OF PREVIOUS PERIOD
dt = sy-datum.
*get current period
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
i_date = dt
i_periv = 'M3' "apr to march 4 spl periods
IMPORTING
e_buper = buper
e_gjahr = gjahr
EXCEPTIONS
input_false = 1
t009_notfound = 2
t009b_notfound = 3
OTHERS = 4.
*fetch previous period
CALL FUNCTION 'CKML_F_GET_PREVIOUS_PERIOD'
EXPORTING
input_period = buper
input_year = gjahr
input_periv = 'M3'
IMPORTING
previous_period = p_buper
previous_year = p_gjahr.
SELECT SINGLE * FROM mardh
WHERE matnr = p_matnr
AND werks = p_werks
AND lfmon = p_buper
AND lfgja = p_gjahr.
IF sy-subrc = 0.
CLOSING STOCK = mardh-labst.
ENDIF.
*to calculate current stock-----
SELECT * FROM mard
INTO CORRESPONDING FIELDS OF TABLE it_mard
WHERE matnr = it_marc-matnr
AND werks = p_werks.
IF NOT it_mard[] IS INITIAL.
LOOP AT it_mard.
t_mard-matnr = it_mard-matnr.
t_mard-labst = it_mard-labst.
COLLECT t_mard.
ENDLOOP.
READ TABLE t_mard INDEX 1.
CURRENT STOCK= t_mard-labst.
ENDIF.
thanks
mrutyun^ -
Wanted to fetch data from ref cursor to nested pl/sql table getting an erro
create or replace type "DEPT12" as object(dno number(2),dname varchar2(30),loc varchar2(50));
create or replace type dept_tab as table of "DEPT12"
create or replace type "LOC12" as object(locno number,loc_name varchar2(100))
create or replace type loc_tab as table of "LOC12"
create or replace type dept_loc_rec1 as object (dept_dt dept_tab,eno number,loc_dt loc_tab);
create type dept_loc_tb as table of dept_loc_rec1
create table dept_loc_tb_bk1(dept_dt dept_tab,eno number,loc_dt loc_tab)
NESTED TABLE dept_dt
STORE AS dept_tab12,
NESTED TABLE loc_dt
STORE AS loc_tab12
insert into dept_loc_tb_bk1 values(dept_tab(dept12(3,'ABD','LOC')
,dept12(4,'ABD','LOC')
,dept12(5,'ABD','LOC')),3,loc_tab(loc12(21,'AAB'),
loc12(22,'AAB'),
loc12(23,'AAB')));
when I am trying to fetch data from ref cursor to pl/sql table which i am getting an error ora-06504: pl/sql : Return types of result set variables or query do not match.
I have created a nested table of same as the nested pl/sql object table dept_loc_tb and i have declared the lv_dept_loc_tb of same dept_loc_tb but getting an above error when trying to fetch into that variable.
Please any one who can solve my problem.
declare
type cr is ref cursor;
cr_obj cr;
lv_dept_loc_tb dept_loc_tb;
begin
open cr_obj for select dept_dt,eno,loc_dt from dept_loc_tb_bk1;
fetch cr_obj bulk collect into lv_dept_loc_tb;
close cr_obj;
end;Your query selects 3 separate columns therefore requires 3 collections of corresponding types. You want to treat those 3 columns as an object of DEPT_LOC_REC1 type:
SQL> declare
2 type cr is ref cursor;
3 cr_obj cr;
4
5 lv_dept_loc_tb dept_loc_tb;
6
7 begin
8 open cr_obj for select dept_dt,eno,loc_dt from dept_loc_tb_bk1;
9 fetch cr_obj bulk collect into lv_dept_loc_tb;
10 close cr_obj;
11 end;
12 /
declare
ERROR at line 1:
ORA-06504: PL/SQL: Return types of Result Set variables or query do not match
ORA-06512: at line 9
SQL> declare
2 type cr is ref cursor;
3 cr_obj cr;
4
5 lv_dept_loc_tb dept_loc_tb;
6
7 begin
8 open cr_obj for select DEPT_LOC_REC1(dept_dt,eno,loc_dt) from dept_loc_tb_bk1;
9 fetch cr_obj bulk collect into lv_dept_loc_tb;
10 close cr_obj;
11 end;
12 /
PL/SQL procedure successfully completed.
SQL> SY.
P.S. Discover sys_refcursor. -
Finder doesn't stop opening and closing!
Help!
I was playing Sims 2 (an addiction) a few minutes ago, and I took some video captures. When I tried opening and viewing them on Quicktime, OS X started acting up. Finder won't stop opening and closing now, it opens and closes almost instantly. It all started happening when I tried opening Quicktime. I tried searching Apple.com, and the web for answers and I haven't had any luck. My system's specs are:
Mac Mini 1.42Ghz
1GB of RAM (recently installed)
Mac OS X Tiger 10.4.7
At the time the problem occured, I was running AIM, Sims 2, and Quicktime. This has never happened before. I tried Shutting Down and coming back again but it kept doing it. I removed the Sims 2 CD and shut down and after awhile turned it back on, still on going. Right now the computer went into Screen Saver mode and I can see the cursor blinking in and out...
Please help this is really frustrating...
Mac Mini 1.42Ghz Mac OS X (10.4.7) 1GB RamSee if you can boot up in safe mode. To do so, restart and hold down the shift key until it boots. It will take longer to boot because it will be running a file system check while booting so be patient.
If that helps try rebooting again the normal way.
If the problem comes back when you boot the normal way then reboot in to safe mode again and then try deleting the finder preferences file. Instructions on how to do this are available here:
http://www.thexlab.com/faqs/finder.html
I would then do some basic maintenance on your Mac as outlined in the following FAQ, just to be on the safe side.
http://www.thexlab.com/faqs/maintainingmacosx.html
Maybe you are looking for
-
Safari 4.1.2 won't open
MacPro, OS 10.4.11, Safari 4.1.2 stopped opening. The Safari window comes up, but the rainbow ball spins eternally and the icon in the dock (when clicked) says "application not responding." I tried dumping the Safari plist, but still won't open. Trie
-
Hi SRM Gurus, My requirement is to display only those Purchase Orders to the user that he has created once user clicks on Purchasing Tab->Ordered or Refresh Button . In order to achieve this requirement, I implemented the method 'BBP_WF_LIST' of BADI
-
Help! PPT to Mov to MPEG-No Sound
I've converted my powerpoint a movie file and then an mpeg file using qt pro. The picture comes in great but my sound is terrible! How do I fix this? Any help would be wonderful!
-
How to create a Function Module
Hi Please tell me the procedure to create a function module. Thanks in advance, Priya
-
Cookies reappear after removing all website data & Safari reset
Os X Mavericks - Cookies reappear after removing all website data & Safari reset