Short Dump on Inner Join
Hello Experts,
I'm trying to write a Inner join on VBAK and VBAP because i need to get data from both tables. When I try to execute the following code I'm getting a short dump "Error in module RSQL of the database Interface". Can anybody see what's wrong with this select.
begin of t_sales_order,
vbeln type vbak-vbeln, "Sales Order
auart type vbak-auart, "Order Type
audat type vbak-audat, "Shipment Creation date field
posnr type vbap-posnr, "Items
kdmat type vbap-matnr, "Lead Pin
cuobj type vbap-cuobj, "Configuration Object ID
end of t_sales_order,
data: lwa_sales_order type t_Sales_Order.
select single avbeln aaudat a~auart
bposnr bkdmat b~cuobj
into lwa_sales_order
from vbak as a inner join vbap as b
on avbeln = bvbeln
where b~kdmat = pv_pin_number.
Many thanks in advance.
Hi
Your internal table fields sequences are not followed in Inner Join.
begin of t_sales_order,
vbeln type vbak-vbeln, "Sales Order
auart type vbak-auart, "Order Type
audat type vbak-audat, "Shipment Creation date field
posnr type vbap-posnr, "Items
kdmat type vbap-matnr, "Lead Pin
cuobj type vbap-cuobj, "Configuration Object ID
end of t_sales_order,
select single a~vbeln *a~auart* a~audat
b~posnr b~kdmat b~cuobj
into lwa_sales_order
from vbak as a inner join vbap as b
on a~vbeln = b~vbeln
where b~kdmat = pv_pin_number.
Please check the above code
Shiva
Similar Messages
-
Hi ,
I am selecting data (Around 100 fields)from 4 different tables(a,b,c,d) using INNER JOIN .I get the Runtime error (DUMP) SAPSQL_AMBIGUOUS_FIELDNAME .Since one of the selection field is availble in both c & d tables but i need that to be selected from c alone.
Now i have used Select * to select the fields.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE int_tab
FROM a AS a INNER JOIN b AS b
ON a~key1 = b~key1
INNER JOIN c as c
on c~key2 = a~key2
INNER JOIN d as d
on d~key2 = a~key2
where......
thanks,
sriniHi Chellama,
although this thread is already passed, you might be interested in understanding the use of an ALIAS in open SQL clauses:
You can use the AS clause to define a new name (alias) for a fieldname or table name.
Use select a b c as d into corresponding fields of destination if you want the values of fields a and b to be moved to fields a and b of the destination structure but the value of field c to go to field d of destination structure.
For table names it is the same logic. Yor sample code
select a~ xxxx
a~key1
b~key1
b~yyyy
INTO CORRESPONDING FIELDS OF TABLE int_tab
FROM a AS db_tab1 INNER JOIN b AS db_tab2
ON a~key1 = b~key1
is syntactically wrong because you defined the alias db_tab1for table a and db_tab2 for table b. Now the fields akey1 and so on are unknown, you could use only db_tab1key1 etc.
In Join conditions, you will almost never need an alias clause. Corrected code is
select a~xxxx
a~key1
b~key1
b~yyyy
INTO CORRESPONDING FIELDS OF TABLE int_tab
FROM a
INNER JOIN b
ON a~key1 = b~key1
This is much more transparent for the one who has to read and understand the code.
Regards,
Clemens -
CL_RSPLS_CR_CONTROLLER method inner join short dump
Hi guys,
i have characteristic relationship usage but i created a new concept for characteristic combinations creation. We have one table with all characteristics are maintained We want to use one single table to maintain all relations. The class created with the create method implemented is working and we do have the right entries in table c_th_chas. This table then goes into standard coding and is transformed. Afterwards method complete_combis is executed and within this method there is the method INNER_JOIN_steps. There method INNER_JOIN is executed. And this is thge method which dumps because method INNER_JOIN has a part beggining with the comment intersection of characteristics is empty, so build the cart.product.. From 13 characetristics in the table 6 are filled and 7 are empty . Maybe 8 times i am able to to run the loop but then the values of the tables is increasing immensly and a short time is thrown with no more internal table space... --> no more memory.
The problem seems to be the empty characetristics and the building of the cart. product. The command
INSERTc_s_chas INTO TABLE e_th_chas.
is to much for over 10 Mio records and a short dump is thrown.
Is there any workaround for this problem? Can someone give me a hint.
Thanks and regards,
MuratHi Gregor,
thank you for your very helpful answer. With ticking this flag no automatic combinations were created and the wished characetristic relations were displayed. But after ticking this flag other workbooks crashed of invalid combinations which worked fine before witout the characteristic relationship class activation. The issue is as following:
i have a lot of characteristics in the realtime planning cube. My intention was to make one big table with most of the characteristics in it to build characteristic relations. At the moment we do have some tables and maintaining them gets komplex. One table i for all is the target.We have workbooks where we dont want use characteristic relations so we have a characetristic embedded in constant selections (structure) in the query and other characteristics with Access Type for Result Values in Master Data and Filter Value Selection Durinbg Query Execution with Values in Master data Table. For these workbooks i dont want characteristic relationships but we also have the opposite queries with characetreistics with ACCESS Type for Result Values with CHARACTERISTIC RELATIONSHIP and Filter value Selection During Query execution with CHARACTERISTIC RELATIONSHIP. In these workbooks i want to use characetristic relationships and the table in the others not. Now the wueries where i want to use CRRs are correct but at the other workbooks also the table and CRR class is executed but i dont want them to get restricted by CRRS and also there is no characetristic using ACCESS Type for Result Values with CHARACTERISTIC RELATIONSHIP and also Filter value Selection During Query execution with CHARACTERISTIC Relationdships.
But despite why is CRR class executed. How can i solve it?
I would appreciate if you or someone could suggest me something here.
Thanks and kind regards,
Murat -
Hi forum,
Pls help me out...I'm getting short dump if i execute this..
pls correct the code.......
REPORT ZPAY_REG NO STANDARD PAGE HEADING line-size 150 line-count
65(3).
TYPE-POOLS: slis.
TABLES:
payr,
t012,
t012k,
t51r5.
Data : begin of it occurs 0,
zbukr like payr-zbukr, "paying company code
hbkid like payr-hbkid, "house bank id
hktid like payr-hktid, "account id
bankl like t012-bankl, "bank key
bankn like t012k-bankn, "bank account
checf like payr-checf, "check number
waers like payr-waers, "currency
rwbtr like payr-rwbtr, "amount
bancd like payr-bancd, "check encashment date
vblnr like payr-vblnr, "payment document no
pernr like payr-pernr, "personnel number
voidr like payr-voidr, "void reason code
rzawe like payr-rzawe, "payment method
laufd like payr-laufd, "checks from payment run
empfg like payr-empfg, "payee code
gjahr like payr-gjahr, "fiscal year
duedt like t51r5-duedt, "due date
zaldt like payr-zaldt, "payment date
znme1 like payr-znme1, "payee name
rec_belnr like payr-rec_belnr, " voucher number
end of it.
*"Payment Register
*A listing of payments made by vendor for a specific payment run or
*group of runs. Data elements include but not limited to:
** Payment date
* Pay
* Payment number
* Payee name/number
* Voucher number
* Amount
* Period from/to
*Frequency: Every payment run, ad hoc for a timeframe, monthly
DATA: it_fldcat TYPE slis_fieldcat_alv OCCURS 0,
wa_fldcat TYPE slis_fieldcat_alv.
DATA : it_sort TYPE slis_sortinfo_alv OCCURS 0,
wa_sort TYPE slis_sortinfo_alv.
DATA: it_events TYPE slis_t_event,
wa_events TYPE slis_alv_event.
"DATA : v_txt TYPE string.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_zaldt FOR payr-zaldt, " payment date
s_vblnr FOR payr-vblnr, " payment document number
s_znme1 FOR payr-znme1, " payee name
s_rec FOR payr-rec_belnr, "voucher number
s_waers for payr-waers. "amount
s_duedt for t51r5-duedt. "due date
SELECTION-SCREEN END OF BLOCK b1.
SELECT a~zbukr
a~hbkid
a~hktid
a~checf
a~waers
a~rwbtr
a~bancd
a~vblnr
a~pernr
a~voidr
a~rzawe
a~laufd
a~empfg
a~gjahr
a~zaldt
a~znme1
a~rec_belnr
b~bankl
c~bankn
d~duedt
INTO CORRESPONDING FIELDS OF TABLE it
FROM payr AS a
INNER JOIN t012 AS b
ON ahbkid = bhbkid
inner join t012k as c
on bhbkid = chbkid
and on ahbkid = chbkid
inner join t51r5 as d
on cbukrs = dbukrs
and on awaers = dwaers
WHERE a~zaldt IN s_zaldt
AND a~vblnr IN s_vblnr
AND a~znme1 IN s_znme1
AND a~rec_belnr IN s_rec
AND a~waers IN s_waers.
loop at it.
write : / it-zbukr, it-hbkid, it-hktid, it-checf, it-waers, it-rwbtr,
it-bancd, it-vblnr, it-pernr, it-voidr, it-rzawe, it-laufd, it-empfg,
it-gjahr, it-zaldt, it-znme1, it-rec_belnr, it-bankl, it-bankn, it-duedt
endloop.
**--show data--
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' "Displaying data in grid format
EXPORTING
i_callback_program = sy-repid
it_fieldcat = it_fldcat "fieldcatalog
it_sort = it_sort[] "Sort
it_events = it_events
TABLES
t_outtab = it "internal table to output
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
" SHOW_DATA
PERFORM BUILD_FLDCAT.
*& Form BUILD_FLDCAT
FORM build_fldcat .
DEFINE bld_fcat. "Macro to create manual field catalog
wa_fldcat-col_pos = &1.
wa_fldcat-fieldname = &2.
wa_fldcat-outputlen = &3.
wa_fldcat-seltext_s = &4.
wa_fldcat-ddictxt = &5.
append wa_fldcat to it_fldcat.
clear wa_fldcat.
END-OF-DEFINITION.
bld_fcat 1 'zbukr' 4 'Payee Company Code' 'L'.
bld_fcat 2 'hbkid' 5 'Short Key for a house bank' 'L'.
bld_fcat 3 'hktid' 5 'ID for account details' 'L'.
bld_fcat 4 'checf' 13 'Check number from' 'L'.
bld_fcat 5 'waers' 5 'Currency Key' 'L'.
bld_fcat 6 'rwbtr' 13 'Amount paid in tha payment currency' 'L'.
bld_fcat 7 'bancd' 8 'Check encashment date' 'L'.
bld_fcat 8 'vblnr' 10 'Document number of the payment document' 'L'.
bld_fcat 9 'pernr' 8 'Personnel number' 'L'.
bld_fcat 10 'voidr' 2 'Check region code' 'L'.
bld_fcat 11 'rzawe' 1 'payment method' 'L'.
bld_fcat 12 'laufd' 8 'Date on which the program is to be run' 'L'.
bld_fcat 13 'empfg' 16 'Payee code' 'L'.
bld_fcat 14 'gjahr' 4 'Fiscal Year' 'L'.
bld_fcat 15 'zaldt' 8 'Probable payment date' 'L'.
bld_fcat 16 'znme1' 35 'Payee Name' 'L'.
bld_fcat 17 'rec_belnr' 10 'Accounting Document Number Ref to Vocher Number' 'L'.
bld_fcat 18 'bankl' 15 'Bank key' 'L'.
bld_fcat 19 'bankn' 18 'Bank account number' 'L'.
bld_fcat 20 'duedt' 8 'Due Date' 'L'.
LOOP AT it_fldcat INTO wa_fldcat.
IF wa_fldcat-fieldname = 'LIFNR'.
wa_fldcat-key = 'X'.
ELSEIF wa_fldcat-fieldname = 'DMBTR'.
wa_fldcat-do_sum = 'X'.
ELSEIF wa_fldcat-fieldname = 'WRBTR'.
wa_fldcat-do_sum = 'X'.
ENDIF.
MODIFY it_fldcat FROM wa_fldcat.
CLEAR wa_fldcat.
ENDLOOP.
ENDFORM.Hi Mahathi,
Please check the below code which is corrected.
*& Report ZPAY_REG *
REPORT ZPAY_REG NO STANDARD PAGE HEADING line-size 150 line-count
65(3).
TYPE-POOLS: slis.
TABLES:
payr,
t012,
t012k,
t51r5.
DATA : BEGIN OF it OCCURS 0,
zbukr LIKE payr-zbukr, "paying company code
hbkid LIKE payr-hbkid, "house bank id
hktid LIKE payr-hktid, "account id
bankl LIKE t012-bankl, "bank key
bankn LIKE t012k-bankn, "bank account
checf LIKE payr-checf, "check number
waers LIKE payr-waers, "currency
rwbtr LIKE payr-rwbtr, "amount
bancd LIKE payr-bancd, "check encashment date
vblnr LIKE payr-vblnr, "payment document no
pernr LIKE payr-pernr, "personnel number
voidr LIKE payr-voidr, "void reason code
rzawe LIKE payr-rzawe, "payment method
laufd LIKE payr-laufd, "checks from payment run
empfg LIKE payr-empfg, "payee code
gjahr LIKE payr-gjahr, "fiscal year
duedt LIKE t51r5-duedt, "due date
zaldt LIKE payr-zaldt, "payment date
znme1 LIKE payr-znme1, "payee name
rec_belnr LIKE payr-rec_belnr, " voucher number
END OF it.
*"Payment Register
*A listing of payments made by vendor for a specific payment run or
*group of runs. Data elements include but not limited to:
** Payment date
* Pay
* Payment number
* Payee name/number
* Voucher number
* Amount
* Period from/to
*Frequency: Every payment run, ad hoc for a timeframe, monthly
DATA: it_fldcat TYPE slis_fieldcat_alv OCCURS 0,
wa_fldcat TYPE slis_fieldcat_alv.
DATA : it_sort TYPE slis_sortinfo_alv OCCURS 0,
wa_sort TYPE slis_sortinfo_alv.
DATA: it_events TYPE slis_t_event,
wa_events TYPE slis_alv_event.
"DATA : v_txt TYPE string.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_zaldt FOR payr-zaldt, " payment date
s_vblnr FOR payr-vblnr, " payment document number
s_znme1 FOR payr-znme1, " payee name
s_rec FOR payr-rec_belnr, "voucher number
s_waers FOR payr-waers, "amount
s_duedt FOR t51r5-duedt. "due date
SELECTION-SCREEN END OF BLOCK b1.
SELECT a~zbukr
a~hbkid
a~hktid
a~checf
a~waers
a~rwbtr
a~bancd
a~vblnr
a~pernr
a~voidr
a~rzawe
a~laufd
a~empfg
a~gjahr
a~zaldt
a~znme1
a~rec_belnr
b~bankl
c~bankn
d~duedt
INTO CORRESPONDING FIELDS OF TABLE it
FROM payr AS a
INNER JOIN t012 AS b
ON ahbkid = bhbkid
INNER JOIN t012k AS c
ON bhbkid = chbkid
AND ahbkid = chbkid
INNER JOIN t51r5 AS d
ON cbukrs = dbukrs
AND awaers = dwaers
WHERE a~zaldt IN s_zaldt
AND a~vblnr IN s_vblnr
AND a~znme1 IN s_znme1
AND a~rec_belnr IN s_rec
AND a~waers IN s_waers.
*LOOP AT it.
WRITE : / it-zbukr, it-hbkid, it-hktid, it-checf, it-waers, it-rwbtr,
it-bancd, it-vblnr, it-pernr, it-voidr, it-rzawe, it-laufd, it-empfg,
*it-gjahr, it-zaldt, it-znme1, it-rec_belnr, it-bankl, it-bankn,
*it-duedt
*ENDLOOP.
*--show data--
" SHOW_DATA
PERFORM build_fldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' "Displaying data in grid format
EXPORTING
i_callback_program = sy-repid
it_fieldcat = it_fldcat[] "fieldcatalog
it_sort = it_sort[] "Sort
it_events = it_events
TABLES
t_outtab = it "internal table to output
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc = 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*& Form BUILD_FLDCAT
FORM build_fldcat .
DEFINE bld_fcat. "Macro to create manual field catalog
wa_fldcat-col_pos = &1.
wa_fldcat-fieldname = &2.
wa_fldcat-outputlen = &3.
wa_fldcat-seltext_s = &4.
wa_fldcat-ddictxt = &5.
append wa_fldcat to it_fldcat.
clear wa_fldcat.
END-OF-DEFINITION.
bld_fcat 1 'zbukr' 4 'Payee Company Code' 'L'.
bld_fcat 2 'hbkid' 5 'Short Key for a house bank' 'L'.
bld_fcat 3 'hktid' 5 'ID for account details' 'L'.
bld_fcat 4 'checf' 13 'Check number from' 'L'.
bld_fcat 5 'waers' 5 'Currency Key' 'L'.
bld_fcat 6 'rwbtr' 13 'Amount paid in tha payment currency' 'L'.
bld_fcat 7 'bancd' 8 'Check encashment date' 'L'.
bld_fcat 8 'vblnr' 10 'Document number of the payment document' 'L'.
bld_fcat 9 'pernr' 8 'Personnel number' 'L'.
bld_fcat 10 'voidr' 2 'Check region code' 'L'.
bld_fcat 11 'rzawe' 1 'payment method' 'L'.
bld_fcat 12 'laufd' 8 'Date on which the program is to be run' 'L'.
bld_fcat 13 'empfg' 16 'Payee code' 'L'.
bld_fcat 14 'gjahr' 4 'Fiscal Year' 'L'.
bld_fcat 15 'zaldt' 8 'Probable payment date' 'L'.
bld_fcat 16 'znme1' 35 'Payee Name' 'L'.
bld_fcat 17 'rec_belnr' 10 'Account DocuNumberRef to Vocher Number' 'L'.
bld_fcat 18 'bankl' 15 'Bank key' 'L'.
bld_fcat 19 'bankn' 18 'Bank account number' 'L'.
bld_fcat 20 'duedt' 8 'Due Date' 'L'.
LOOP AT it_fldcat INTO wa_fldcat.
IF wa_fldcat-fieldname = 'LIFNR'.
wa_fldcat-key = 'X'.
ELSEIF wa_fldcat-fieldname = 'DMBTR'.
wa_fldcat-do_sum = 'X'.
ELSEIF wa_fldcat-fieldname = 'WRBTR'.
wa_fldcat-do_sum = 'X'.
ENDIF.
MODIFY it_fldcat FROM wa_fldcat.
CLEAR wa_fldcat.
ENDLOOP.
ENDFORM. "build_fldcat
Please reward points if it is answered and close the thread.
Regards,
Hari -
Short dump while export grid alv with subtotals.
hello,
its strange and i face first time that my grid alv report goin to short dump while i done subtotals and send it to local file thru export.
if am not doing subtotals then export it to local file it goin fine.
whats it has problem plz give ur helping hends.
here i copied a dump msg also.
Short text
Error at assignment: Overwritten protected field.
What happened?
Error in the ABAP Application Program
The current ABAP program "SAPLKKBL" had to be terminated because it has
come across a statement that unfortunately cannot be executed.
Error analysis
A new value is to be assigned to the field "<L_UNIT>", although this field is
entirely or partly protected against changes.
The following are protected against changes:
- Character literals or numeric literals
- Constants (CONSTANTS)
- Parameters of the category IMPORTING REFERENCE for functions and
methods
- Untyped field symbols not yet assigned a field using ASSIGN
- TABLES parameters if the actual parameter is protected against changes
- USING reference parameters and CHANGING parameters for FORMs, if the
actual parameter is protected against changes and
- Accesses using field symbols if the field assigned using ASSIGN is
protected (or partially protected, e.g. key components of an internal
table with the type SORTED or HASHED TABLE) against changes
- Accesses using references, if the field bound to the reference is
protected (or partially protected) against changes
- External write accesses to READ-ONLY attributes,
- Content of a shared object area instance accessed using a shared lock
(ATTACH_FOR_READ).
regards amit.& Object Id : &
& Object Name : &
& Function Module Name : Sales Register &
& Transaction Code : &
& Author : Amit gujargoud &
& Module Name : SD &
& Sub-Module : &
& Program Type : Dialog Create Date : 02/02/2007 &
& SAP Release : ECC 6.0 &
& Description : Sales Register - Detail &
*& Report ZSALESREGISTER
REPORT zsd_salesregister.
*& TYPE-POOLS
TYPE-POOLS : slis.
*& TABLES
TABLES: vbrp, "Billing Document: Item Data
vbrk, "Billing Document: Header Data
lips, "SD document: Delivery: Item data
lfa1, "Vendor Master (General Section)
kna1, "General Data in Customer Master
vbak, "Sales Document: Header Data
vbpa, "Sales Document: Partner (Gopal)
likp, "SD Document: Delivery Header Data
vbap, "Sales Document: Item Data
vbkd, "Sales Document: Business Data
mara. "General Material Data
*& DATA DECLARATION
DATA: BEGIN OF i_report OCCURS 100,
vbeln LIKE vbrp-vbeln, "Billing Document
posnr LIKE vbrp-posnr,
matnr LIKE mara-matnr ,
aubel LIKE vbrp-aubel, "Sales Document
fkimg LIKE vbrp-fkimg, "Actual billed quantity
vrkme LIKE vbrp-vrkme, "Sales unit
arktx LIKE vbrp-arktx, "Short text for sales order item
vgbel LIKE vbrp-vgbel, "Doc number of the reference document
werks LIKE vbap-werks,
vkgrp LIKE vbrp-vkgrp,
fklmg LIKE vbrp-fklmg,
volum LIKE vbrp-volum,
vkbur LIKE vbrp-vkbur,
vtweg_auft LIKE vbrp-vtweg_auft,
auart LIKE vbak-auart,
tabix LIKE sy-tabix, "Internal Table, Current Row Index
name1 LIKE kna1-name1, "Name1
exnum LIKE j_1iexchdr-exnum, "Official Excise Document Number
orqty TYPE p DECIMALS 0,
penqty TYPE p DECIMALS 0, "Cumulative order qty in sls units
openqty TYPE p DECIMALS 0, "Cumulative order qty in sls units
ean11 LIKE lips-ean11, "International Article No(EAN/UPC)
volum LIKE lips-volum,
lgmng LIKE lips-lgmng,
traid LIKE likp-traid,
ort01 LIKE lfa1-ort01, "City
lifnr LIKE lfa1-lifnr, "A/c Number of Vendor or Creditor
netwr LIKE vbrp-netwr, "Net val of bill item in doc currency
kunnr LIKE vbak-kunnr, "Sold-to party
adrnr LIKE vbpa-adrnr, "Address
city1 LIKE adrc-city1, "City
tprtr LIKE lfa1-name1, "Name 1
knumv LIKE konv-knumv, "Number of the document condition
kposn LIKE konv-kposn,
rate LIKE konv-kbetr, "Rate (cond amount or percentage)
bas_val LIKE konv-kwert, "Rate (cond amount or percentage)
exc_duty LIKE konv-kwert, "Rate (cond amount or percentage)
ed_cess LIKE konv-kwert, "Rate (cond amount or percentage)
freight LIKE konv-kwert, "Rate (cond amount or percentage)
pack LIKE konv-kwert, "Rate (cond amount or percentage)
cst LIKE konv-kwert, "Rate (cond amount or percentage)
vat LIKE konv-kwert, "Rate (cond amount or percentage)
ent_tax LIKE konv-kwert, "Rate (cond amount or percentage)
tot_inv LIKE konv-kwert, "Rate (cond amount or percentage)
tot_inv_round LIKE konv-kwert, "Rate (cond amount or percentage)
disc_tot LIKE konv-kwert, "Discount total - Z001 to Z020
vat_rate LIKE konv-kbetr,
cst_rate LIKE konv-kbetr,
lst_rate LIKE konv-kbetr,
mwsbk LIKE vbrk-mwsbk,
bas_tax LIKE konv-kwert,
dev_tax LIKE konv-kwert,
tcs_tax LIKE konv-kwert,
bas_tot LIKE konv-kwert,
lst LIKE konv-kwert,
vkorg LIKE vbak-vkorg,
mvgr1 LIKE mvke-mvgr1,
mvgr2 LIKE mvke-mvgr2,
mvgr3 LIKE mvke-mvgr3,
mvgr4 LIKE mvke-mvgr4,
mvgr5 LIKE mvke-mvgr5,
text1 LIKE tvm1t-bezei,
text2 LIKE tvm1t-bezei,
text3 LIKE tvm1t-bezei,
text4 LIKE tvm1t-bezei,
text5 LIKE tvm1t-bezei,
bismit_area TYPE p DECIMALS 4, " Size (L*B) in mm
face_area TYPE p DECIMALS 2, " Face Area Declaration
notional_area TYPE p DECIMALS 2,
stock_pcs TYPE p , " decimals 3 Pcs of Stock
labst LIKE mard-labst, " Valuated Unrestricted-Use Stock
bismt LIKE mara-bismt, " Size (L*B) in mm
normt LIKE mara-normt, " Industry Standard Description
temp TYPE p DECIMALS 2,
temp1 TYPE p DECIMALS 2,
temp2 TYPE p DECIMALS 2,
temp3 TYPE p DECIMALS 2,
temp4 TYPE p DECIMALS 2,
temp5 TYPE p DECIMALS 2,
temp6 TYPE p DECIMALS 2,
temp7 TYPE p DECIMALS 2,
temp8 TYPE p DECIMALS 2,
temp9 TYPE p DECIMALS 2,
temp10 TYPE p DECIMALS 2,
temp11 TYPE p DECIMALS 2,
temp12 TYPE p DECIMALS 2,
temp13 TYPE p DECIMALS 0,
temp14 TYPE p DECIMALS 0,
temp15 TYPE p DECIMALS 0,
temp16 TYPE p DECIMALS 2,
temp17 TYPE p DECIMALS 2,
temp18 TYPE p DECIMALS 2,
temp19 TYPE p DECIMALS 2,
temp20 TYPE p DECIMALS 2,
temp21 TYPE p DECIMALS 2,
waybill(20) TYPE c,
audat LIKE vbak-audat, "Document Date (Date Received/Sent)
lgort LIKE vbap-lgort, "Storage location
lgobe LIKE t001l-lgobe, "Description of storage location
erdat LIKE vbrk-erdat, "Date on which the record was created
exdat LIKE j_1iexchdr-exdat, "Excise Document Date
vbtyp LIKE vbak-vbtyp, "SD document category
acdt LIKE likp-wadat_ist, "Actual goods movement date
fkdat LIKE vbrk-fkdat,
ship LIKE kna1-name1, "Name1 (Ship-to party)
fksto LIKE vbrk-fksto,
fkart LIKE vbrk-fkart,
bezei LIKE t005u-bezei,
vtweg LIKE vbak-vtweg,
spart LIKE vbak-spart,
matkl LIKE mara-matkl,
wgbez LIKE t023t-wgbez,
mtart LIKE mara-mtart,
labor LIKE mara-labor,
ferth LIKE mara-ferth,
lbtxt LIKE t024x-lbtxt,
niels LIKE kna1-niels,
kukla LIKE kna1-kukla,
desc LIKE tvkbt-bezei,
brsch LIKE kna1-brsch,
zeinr LIKE mara-zeinr,
bzirk LIKE vbrk-bzirk,
area_desc LIKE tnlst-bezei,
dist_desc TYPE tkukt-vtext,
taluka_desc TYPE t016t-brtxt,
sales_desc TYPE tvgrt-bezei,
kmein LIKE konv-kmein, "Sales Unit
challan LIKE likp-vbeln,
END OF i_report.
data for MVKE
DATA: BEGIN OF i_report_mvke OCCURS 0,
vbeln LIKE vbrp-vbeln, "Billing Document
aubel LIKE vbrp-aubel, "Sales Document
vkorg LIKE vbak-vkorg,
matnr LIKE mara-matnr ,
vtweg LIKE vbak-vtweg,
END OF i_report_mvke.
***********************TEMP COPY
DATA: BEGIN OF i_report_temp OCCURS 0,
vbeln LIKE vbrp-vbeln, "Billing Document
posnr LIKE vbrp-posnr,
matnr LIKE mara-matnr ,
aubel LIKE vbrp-aubel, "Sales Document
fkimg LIKE vbrp-fkimg, "Actual billed quantity
vrkme LIKE vbrp-vrkme, "Sales unit
arktx LIKE vbrp-arktx, "Short text for sales order item
vgbel LIKE vbrp-vgbel, "Doc number of the reference document
werks LIKE vbap-werks,
vkgrp LIKE vbrp-vkgrp,
fklmg LIKE vbrp-fklmg,
volum LIKE vbrp-volum,
vkbur LIKE vbrp-vkbur,
vtweg_auft LIKE vbrp-vtweg_auft,
auart LIKE vbak-auart,
tabix LIKE sy-tabix, "Internal Table, Current Row Index
name1 LIKE kna1-name1, "Name1
exnum LIKE j_1iexchdr-exnum, "Official Excise Document Number
orqty TYPE p DECIMALS 0,
penqty TYPE p DECIMALS 0, "Cumulative order qty in sls units
openqty TYPE p DECIMALS 0, "Cumulative order qty in sls units
ean11 LIKE lips-ean11, "International Article No(EAN/UPC)
volum LIKE lips-volum,
lgmng LIKE lips-lgmng,
traid LIKE likp-traid,
ort01 LIKE lfa1-ort01, "City
lifnr LIKE lfa1-lifnr, "A/c Number of Vendor or Creditor
netwr LIKE vbrp-netwr, "Net val of bill item in doc currency
kunnr LIKE vbak-kunnr, "Sold-to party
adrnr LIKE vbpa-adrnr, "Address
city1 LIKE adrc-city1, "City
tprtr LIKE lfa1-name1, "Name 1
knumv LIKE konv-knumv, "Number of the document condition
kposn LIKE konv-kposn,
rate LIKE konv-kbetr, "Rate (cond amount or percentage)
bas_val LIKE konv-kwert, "Rate (cond amount or percentage)
exc_duty LIKE konv-kwert, "Rate (cond amount or percentage)
ed_cess LIKE konv-kwert, "Rate (cond amount or percentage)
freight LIKE konv-kwert, "Rate (cond amount or percentage)
pack LIKE konv-kwert, "Rate (cond amount or percentage)
cst LIKE konv-kwert, "Rate (cond amount or percentage)
vat LIKE konv-kwert, "Rate (cond amount or percentage)
ent_tax LIKE konv-kwert, "Rate (cond amount or percentage)
tot_inv LIKE konv-kwert, "Rate (cond amount or percentage)
tot_inv_round LIKE konv-kwert, "Rate (cond amount or percentage)
disc_tot LIKE konv-kwert, "Discount total - Z001 to Z020
vat_rate LIKE konv-kbetr,
cst_rate LIKE konv-kbetr,
lst_rate LIKE konv-kbetr,
mwsbk LIKE vbrk-mwsbk,
bas_tax LIKE konv-kwert,
dev_tax LIKE konv-kwert,
tcs_tax LIKE konv-kwert,
bas_tot LIKE konv-kwert,
lst LIKE konv-kwert,
vkorg LIKE vbak-vkorg,
mvgr1 LIKE mvke-mvgr1,
mvgr2 LIKE mvke-mvgr2,
mvgr3 LIKE mvke-mvgr3,
mvgr4 LIKE mvke-mvgr4,
mvgr5 LIKE mvke-mvgr5,
text1 LIKE tvm1t-bezei,
text2 LIKE tvm1t-bezei,
text3 LIKE tvm1t-bezei,
text4 LIKE tvm1t-bezei,
text5 LIKE tvm1t-bezei,
bismit_area TYPE p DECIMALS 4, " Size (L*B) in mm
face_area TYPE p DECIMALS 2, " Face Area Declaration
notional_area TYPE p DECIMALS 2,
stock_pcs TYPE p , " decimals 3 Pcs of Stock
labst LIKE mard-labst, " Valuated Unrestricted-Use Stock
bismt LIKE mara-bismt, " Size (L*B) in mm
normt LIKE mara-normt, " Industry Standard Description
temp TYPE p DECIMALS 2,
temp1 TYPE p DECIMALS 2,
temp2 TYPE p DECIMALS 2,
temp3 TYPE p DECIMALS 2,
temp4 TYPE p DECIMALS 2,
temp5 TYPE p DECIMALS 2,
temp6 TYPE p DECIMALS 2,
temp7 TYPE p DECIMALS 2,
temp8 TYPE p DECIMALS 2,
temp9 TYPE p DECIMALS 2,
temp10 TYPE p DECIMALS 2,
temp11 TYPE p DECIMALS 2,
temp12 TYPE p DECIMALS 2,
temp13 TYPE p DECIMALS 0,
temp14 TYPE p DECIMALS 0,
temp15 TYPE p DECIMALS 0,
temp16 TYPE p DECIMALS 2,
temp17 TYPE p DECIMALS 2,
temp18 TYPE p DECIMALS 2,
temp19 TYPE p DECIMALS 2,
temp20 TYPE p DECIMALS 2,
temp21 TYPE p DECIMALS 2,
waybill(20) TYPE c,
audat LIKE vbak-audat, "Document Date (Date Received/Sent)
lgort LIKE vbap-lgort, "Storage location
lgobe LIKE t001l-lgobe, "Description of storage location
erdat LIKE vbrk-erdat, "Date on which the record was created
exdat LIKE j_1iexchdr-exdat, "Excise Document Date
vbtyp LIKE vbak-vbtyp, "SD document category
acdt LIKE likp-wadat_ist, "Actual goods movement date
fkdat LIKE vbrk-fkdat,
ship LIKE kna1-name1, "Name1 (Ship-to party)
fksto LIKE vbrk-fksto,
fkart LIKE vbrk-fkart,
bezei LIKE t005u-bezei,
vtweg LIKE vbak-vtweg,
spart LIKE vbak-spart,
matkl LIKE mara-matkl,
wgbez LIKE t023t-wgbez,
mtart LIKE mara-mtart,
labor LIKE mara-labor,
ferth LIKE mara-ferth,
lbtxt LIKE t024x-lbtxt,
niels LIKE kna1-niels,
kukla LIKE kna1-kukla,
desc LIKE tvkbt-bezei,
brsch LIKE kna1-brsch,
zeinr LIKE mara-zeinr,
bzirk LIKE vbrk-bzirk,
area_desc LIKE tnlst-bezei,
dist_desc TYPE tkukt-vtext,
taluka_desc TYPE t016t-brtxt,
sales_desc TYPE tvgrt-bezei,
kmein LIKE konv-kmein, "Sales Unit
challan LIKE likp-vbeln,
END OF i_report_temp.
DATA: BEGIN OF i_vbap OCCURS 0 ,
posnr LIKE vbap-posnr,
vbeln LIKE vbap-vbeln ,
matnr LIKE vbap-matnr ,
werks LIKE vbap-werks,
kwmeng LIKE vbap-kwmeng,
lgort LIKE vbap-lgort,
matkl LIKE mara-matkl,
wgbez LIKE t023t-wgbez,
mtart LIKE mara-mtart,
END OF i_vbap .
DATA : w_temp_cal(20) TYPE c.
DATA : w_face_area TYPE p DECIMALS 4,
w_notinal_area TYPE p DECIMALS 4.
**MVKE
DATA: BEGIN OF itab_mvke OCCURS 0,
matnr LIKE mvke-matnr,
vkorg LIKE vbak-vkorg,
vtweg LIKE mvke-vtweg,
mvgr1 LIKE mvke-mvgr1,
mvgr2 LIKE mvke-mvgr2,
mvgr3 LIKE mvke-mvgr3,
mvgr4 LIKE mvke-mvgr4,
mvgr5 LIKE mvke-mvgr5,
END OF itab_mvke.
**TVM1T
DATA : BEGIN OF itab_tvm1t OCCURS 0,
spras LIKE tvm1t-spras,
mvgr1 LIKE tvm1t-mvgr1,
bezei LIKE tvm1t-bezei,
END OF itab_tvm1t.
DATA : BEGIN OF itab_tvm2t OCCURS 0,
spras LIKE tvm2t-spras,
mvgr2 LIKE tvm2t-mvgr2,
bezei LIKE tvm2t-bezei,
END OF itab_tvm2t.
DATA : BEGIN OF itab_tvm3t OCCURS 0,
spras LIKE tvm3t-spras,
mvgr3 LIKE tvm3t-mvgr3,
bezei LIKE tvm3t-bezei,
END OF itab_tvm3t.
DATA : BEGIN OF itab_tvm4t OCCURS 0,
spras LIKE tvm4t-spras,
mvgr4 LIKE tvm4t-mvgr4,
bezei LIKE tvm4t-bezei,
END OF itab_tvm4t.
DATA : BEGIN OF itab_tvm5t OCCURS 0,
spras LIKE tvm5t-spras,
mvgr5 LIKE tvm5t-mvgr5,
bezei LIKE tvm5t-bezei,
END OF itab_tvm5t.
DATA: itab_t024x TYPE STANDARD TABLE OF t024x WITH HEADER LINE,
it_report LIKE LINE OF i_report OCCURS 0,
i_mvke LIKE LINE OF itab_mvke OCCURS 0.
**VBKD
DATA: BEGIN OF i_vbkd OCCURS 0 ,
vbeln LIKE vbkd-vbeln ,
posnr LIKE vbkd-posnr ,
bzirk LIKE vbkd-bzirk ,
END OF i_vbkd .
DATA: BEGIN OF i_lips OCCURS 0,
vbeln LIKE lips-vbeln,
ean11 LIKE lips-ean11,
volum LIKE lips-volum,
lgmng LIKE lips-lgmng,
waybill(20) TYPE c,
END OF i_lips.
DATA: BEGIN OF i_vbrk OCCURS 0,
vbeln LIKE vbrk-vbeln,
rfbsk LIKE vbrk-rfbsk, "Status for transfer to accounting
erdat LIKE vbrk-erdat, "Dt on which the record was created
fkdat LIKE vbrk-fkdat, "CHANGE MADE BY PARTHA RAHAMAN
fksto LIKE vbrk-fksto, "GOPAL:: CANCELLED DOC. DO NOT PRNT.
netwr LIKE vbrk-netwr,
fkart LIKE vbrk-fkart, "Gopal:when billng typ=s1 do not pnt 1jul
knumv LIKE vbrk-knumv,
mwsbk LIKE vbrk-mwsbk,
bzirk LIKE vbrk-bzirk,
vtweg LIKE vbrk-vtweg,
spart LIKE vbrk-spart,
END OF i_vbrk.
*structure for MARD Table by kalika
DATA : BEGIN OF itab_mard OCCURS 0,
matnr LIKE mard-matnr,
werks LIKE mard-werks,
labst LIKE mard-labst, " Valuated Unrestricted-Use Stock
lgort LIKE mard-lgort, " Storage Location
END OF itab_mard.
*structure for MARD Table by kalika
DATA:BEGIN OF i_kna1 OCCURS 0,
vbeln LIKE vbak-vbeln,
name1 LIKE kna1-name1,
kunnr LIKE kna1-kunnr,
regio LIKE kna1-regio,
bezei LIKE t005u-bezei,
land1 LIKE kna1-land1,
vkgrp LIKE vbak-vkgrp,
niels LIKE kna1-niels,
kukla LIKE kna1-kukla,
brsch LIKE kna1-brsch,
vkbur LIKE vbak-vkbur,
END OF i_kna1.
DATA:BEGIN OF i_t005u OCCURS 0,
spras LIKE t005u-spras,
land1 LIKE t005u-land1,
bland LIKE t005u-bland,
bezei LIKE t005u-bezei,
END OF i_t005u.
DATA:BEGIN OF i_tnlst OCCURS 0,
spras LIKE t005u-spras,
niels LIKE tnlst-niels,
bezei LIKE t005u-bezei,
END OF i_tnlst.
DATA:BEGIN OF itab_tkukt OCCURS 0,
spras LIKE tkukt-spras,
kukla LIKE tkukt-kukla,
vtext LIKE tkukt-vtext,
END OF itab_tkukt.
DATA : BEGIN OF itab_t016t OCCURS 0,
spras LIKE t016t-spras,
brsch LIKE t016t-brsch,
brtxt LIKE t016t-brtxt,
END OF itab_t016t.
DATA : BEGIN OF itab_tvgrt OCCURS 0,
spras LIKE tvgrt-spras,
vkgrp LIKE tvgrt-vkgrp,
bezei LIKE tvgrt-bezei,
END OF itab_tvgrt.
*DATA: i_t005u TYPE STANDARD TABLE OF t005u WITH HEADER LINE.
DATA:BEGIN OF i_kna2 OCCURS 0,
kunnr LIKE kna1-kunnr,
name1 LIKE kna1-name1, " For Ship-to-Party
END OF i_kna2.
DATA:BEGIN OF i_vbak OCCURS 0,
vbeln LIKE vbak-vbeln,
vbtyp LIKE vbak-vbtyp,
audat LIKE vbak-audat,
auart LIKE vbak-auart,
vtweg LIKE vbak-vtweg,
spart LIKE vbak-spart,
vkbur LIKE vbak-vkbur,
vkorg LIKE vbak-vkorg,
END OF i_vbak.
DATA:BEGIN OF i_adrc OCCURS 0,
vbeln LIKE vbpa-vbeln,
kunnr LIKE kna1-kunnr,
city1 LIKE adrc-city1,
name1 LIKE kna1-name1, "Name1 (Ship-to party)
END OF i_adrc.
DATA:BEGIN OF i_lfa1 OCCURS 0,
lifnr LIKE vbpa-lifnr,
vbeln LIKE vbpa-vbeln,
name1 LIKE lfa1-name1,
END OF i_lfa1.
DATA : BEGIN OF it_knumv OCCURS 0,
vbeln LIKE vbrk-vbeln,
knumv LIKE vbrk-knumv,
END OF it_knumv.
DATA : BEGIN OF it_rate OCCURS 0,
ksteu LIKE konv-ksteu, "Condition control
knumv LIKE konv-knumv, "Number of the document condition
kschl LIKE konv-kschl, "Condition type
kbetr LIKE konv-kbetr, "Rate (condition amount or percentage)
kwert LIKE konv-kwert, "Condition value
kposn LIKE konv-kposn,
kmein LIKE konv-kmein, "Sales Unit
END OF it_rate.
DATA: BEGIN OF itab_exnum OCCURS 0,
exnum LIKE j_1iexchdr-exnum, "Official Excise Document Number
exdat LIKE j_1iexchdr-exdat, "Excise Document Date
rdoc LIKE j_1iexchdr-rdoc, "Reference Document 1
status LIKE j_1iexchdr-status,
END OF itab_exnum.
DATA: BEGIN OF itab_qty OCCURS 0,
kwmeng LIKE vbap-kwmeng,
vbeln LIKE vbap-vbeln,
lgort LIKE vbap-lgort,
END OF itab_qty.
*DATA: BEGIN OF i_stloc OCCURS 0,
lgort LIKE t001l-lgort,
lgobe LIKE t001l-lgobe,
END OF i_stloc.
DATA:t_line LIKE STANDARD TABLE OF tline INITIAL SIZE 0
WITH HEADER LINE,
" itab_tvkbt LIKE STANDARD TABLE OF tvkbt WITH HEADER LINE,
w_tdname LIKE thead-tdname.
DATA : BEGIN OF itab_tvkbt OCCURS 0,
spras LIKE tvkbt-spras,
vkbur LIKE tvkbt-vkbur,
bezei LIKE tvkbt-bezei,
END OF itab_tvkbt.
DATA: BEGIN OF i_exchdr OCCURS 0,
exnum LIKE j_1iexchdr-exnum,
exdat LIKE j_1iexchdr-exdat,
rdoc LIKE j_1iexchdr-rdoc,
END OF i_exchdr.
DATA: BEGIN OF i_likp OCCURS 0,
vbeln LIKE likp-vbeln,
wadat_ist LIKE likp-wadat_ist,
traid LIKE likp-traid,
bolnr LIKE likp-bolnr,
END OF i_likp.
DATA: BEGIN OF i_mara OCCURS 0,
matnr LIKE mara-matnr,
matkl LIKE mara-matkl,
mtart LIKE mara-mtart,
labor LIKE mara-labor,
wgbez LIKE t023t-wgbez,
bismt LIKE mara-bismt,
normt LIKE mara-normt,
ferth LIKE mara-ferth,
zeinr LIKE mara-zeinr,
extwg LIKE mara-extwg,
spart LIKE mara-spart,
END OF i_mara.
DATA: BEGIN OF i_t023t OCCURS 0,
matkl LIKE t023t-matkl,
wgbez LIKE t023t-wgbez,
END OF i_t023t.
DATA : var_length(20) TYPE c,
var_breadth(20) TYPE c.
DATA: p_w_value LIKE konv-kwert.
DATA : it_fieldcat TYPE slis_t_fieldcat_alv, " Event for Table to creater fieldcatalog
wa_fieldcat LIKE LINE OF it_fieldcat, " Work Area for table field catalog
lt_top_of_page TYPE slis_t_listheader, " Header table for top of page
i_layout TYPE slis_layout_alv . " It will fill the layout
gt_event TYPE slis_t_event. " Table Event
*DATA :
"itab_tnlst TYPE STANDARD TABLE OF tnlst WITH HEADER LINE,
" itab_tkukt TYPE STANDARD TABLE OF tkukt WITH HEADER LINE,
*" itab_t016t TYPE STANDARD TABLE OF t016t WITH HEADER LINE,
itab_tvgrt TYPE STANDARD TABLE OF tvgrt WITH HEADER LINE.
*& SELECTION-SCREEN
SELECTION-SCREEN BEGIN OF BLOCK block
WITH FRAME TITLE text-100.
SELECT-OPTIONS: s_date FOR vbrk-fkdat OBLIGATORY,
s_vkbur FOR vbak-vkbur OBLIGATORY,
s_vtweg FOR vbrk-vtweg OBLIGATORY,
s_werks FOR vbap-werks,
s_spart FOR vbrk-spart OBLIGATORY,
s_matkl FOR mara-matkl.
PARAMETERS:
r_opt3 RADIOBUTTON GROUP grp1,
r_opt2 RADIOBUTTON GROUP grp1.
r_opt4 RADIOBUTTON GROUP grp1,
r_opt5 RADIOBUTTON GROUP grp1,
r_opt1 RADIOBUTTON GROUP grp1.
SELECTION-SCREEN END OF BLOCK block.
*& INITIALIZATION
INITIALIZATION.
r_opt2 = 'X'.
*& START-OF-SELECTION.
START-OF-SELECTION.
*select data from VBRP
SELECT vbeln
posnr
matnr
aubel
fkimg
vrkme
arktx
vgbel
werks
vkgrp
fklmg
volum
vkbur
vtweg_auft
FROM vbrp
INTO TABLE i_report
WHERE "erdat IN s_date
AND spart IN s_spart
vkbur IN s_vkbur
AND vtweg_auft IN s_vtweg.
**logic for Pending, Summary & Detail Report
IF
r_opt1 EQ 'X' OR
r_opt2 EQ 'X' OR
r_opt3 EQ 'X'.
SELECT vbeln
rfbsk
erdat
fkdat
fksto
netwr
fkart
knumv
mwsbk
bzirk
vtweg
spart
FROM vbrk INTO TABLE i_vbrk
FOR ALL ENTRIES IN i_report
WHERE "vbeln = i_report-vbeln
" and
fkdat IN s_date
AND fkart IN ('ZBHR', 'ZTZT', 'ZKRP', 'ZRUD', 'ZBSR',
'ZGHT', 'ZKOL', 'ZPTN', 'ZRNC', 'ZCND',
'ZDLH', 'ZGZB', 'ZGUR', 'ZHSR', 'ZJPR',
'ZLKW', 'ZBLR', 'ZCHN', 'ZCBM', 'ZHUB',
'ZHYD', 'ZKOC', 'ZAHD', 'ZIND', 'ZMUM',
*********************MODIFICATION BY CHAKRAPANI (ADDITION OF ZVIJ AND ZHWH ) 18.05.2007
'ZNGP', 'ZPNE', 'ZRPR' , 'ZEXP', 'ZDEM','ZVIJ', 'ZHWH','JEX' )
*********************MODIFICATION BY CHAKRAPANI (ADDITION OF ZVIJ AND ZHWH ) 18.05.2007
AND vtweg IN s_vtweg
AND spart IN s_spart
AND fksto NE 'X'.
IF i_vbrk[] IS NOT INITIAL.
SELECT vbeln
posnr
matnr
aubel
fkimg
vrkme
arktx
vgbel
werks
vkgrp
fklmg
volum
vkbur
vtweg_auft
FROM vbrp
INTO TABLE i_report
FOR ALL ENTRIES IN i_vbrk
WHERE vbeln = i_vbrk-vbeln "erdat IN s_date
AND spart IN s_spart
AND vkbur IN s_vkbur
AND vtweg_auft IN s_vtweg.
ENDIF.
ELSEIF r_opt4 EQ 'X' OR
r_opt5 EQ 'X'.
SELECT vbeln
rfbsk
erdat
fkdat
fksto
netwr
fkart
knumv
mwsbk
bzirk
vtweg
spart
FROM vbrk INTO CORRESPONDING FIELDS OF TABLE i_vbrk
FROM vbrk INTO TABLE i_vbrk
FOR ALL ENTRIES IN i_report
WHERE vbeln = i_report-vbeln
AND fkart EQ 'ZEXP'
AND vtweg IN s_vtweg
AND spart IN s_spart
AND fksto NE 'X'.
ENDIF.
SORT i_vbrk BY vbeln ASCENDING.
ENDIF.
change amit by my self may be removed
IF i_report[] IS NOT INITIAL.
REFRESH it_report.
it_report[] = i_report[].
DELETE ADJACENT DUPLICATES FROM it_report COMPARING aubel.
SORT it_report BY aubel.
*select VBAP data
SELECT posnr vbeln matnr werks
kwmeng lgort
FROM vbap
INTO TABLE i_vbap
FOR ALL ENTRIES IN it_report
WHERE vbeln = it_report-aubel.
ENDIF.
change amit by my self may be removed
*select data from VBKD
IF NOT i_vbap[] IS INITIAL.
SELECT vbeln posnr
FROM vbkd
INTO TABLE i_vbkd
FOR ALL ENTRIES IN i_vbap
WHERE vbeln = i_vbap-vbeln.
ENDIF.
SORT i_vbap BY vbeln ASCENDING.
IF i_report[] IS NOT INITIAL.
REFRESH it_report.
it_report[] = i_report[].
DELETE ADJACENT DUPLICATES FROM it_report COMPARING matnr.
SORT it_report BY matnr.
SELECT
matnr
matkl
mtart
labor
bismt
normt
ferth
zeinr
extwg
spart
FROM mara
INTO TABLE i_mara
FOR ALL ENTRIES IN i_report
WHERE matnr = i_report-matnr
AND spart IN s_spart.
ENDIF.
IF NOT i_mara[] IS INITIAL.
SORT i_mara BY matnr.
SELECT matnr
labst
FROM mard
INTO TABLE itab_mard
FOR ALL ENTRIES IN i_mara
WHERE matnr = i_mara-matnr.
ENDIF.
ENDIF.
DATA : it_mara LIKE LINE OF i_mara OCCURS 0.
IF NOT i_mara[] IS INITIAL.
REFRESH it_mara.
it_mara[] = i_mara[].
DELETE ADJACENT DUPLICATES FROM it_mara COMPARING matkl.
SORT it_mara BY matkl.
SELECT matkl wgbez
FROM t023t
INTO TABLE i_t023t
FOR ALL ENTRIES IN it_mara
WHERE matkl = it_mara-matkl.
*T024X
REFRESH it_mara.
it_mara[] = i_mara[].
DELETE ADJACENT DUPLICATES FROM it_mara COMPARING labor.
SORT it_mara BY labor.
SELECT * FROM t024x
INTO TABLE itab_t024x
FOR ALL ENTRIES IN it_mara
WHERE labor = it_mara-labor
AND spras = sy-langu.
ENDIF.
*begin of change amit
LOOP AT i_vbap.
READ TABLE i_mara WITH KEY matnr = i_vbap-matnr.
IF sy-subrc = 0.
*material type & material group
i_vbap-mtart = i_mara-mtart.
i_vbap-matkl = i_mara-matkl.
ENDIF.
MODIFY i_vbap.
ENDLOOP.
*Material Group Description
*end of change amit
IF i_report[] IS NOT INITIAL.
REFRESH it_report.
it_report[] = i_report[].
DELETE ADJACENT DUPLICATES FROM it_report COMPARING vgbel.
SORT it_report BY vgbel.
SELECT vbeln
ean11
volum
lgmng
FROM lips
INTO TABLE i_lips
FOR ALL ENTRIES IN it_report
WHERE vbeln = it_report-vgbel.
ENDIF.
IF i_report[] IS NOT INITIAL.
REFRESH it_report.
it_report[] = i_report[].
SORT it_report BY vgbel.
DELETE ADJACENT DUPLICATES FROM it_report COMPARING vgbel.
IF i_lips[] IS NOT INITIAL.
SELECT vbeln
wadat_ist
traid
bolnr
FROM likp
INTO TABLE i_likp
FOR ALL ENTRIES IN it_report
WHERE vbeln = it_report-vgbel.
ENDIF.
SORT i_lips BY vbeln ASCENDING.
LOOP AT i_lips.
REFRESH t_line.
CLEAR w_tdname.
w_tdname = i_lips-vbeln.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = 'ZVOW'
language = sy-langu
name = w_tdname
object = 'VBBK'
TABLES
lines = t_line
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
LOOP AT t_line.
CONCATENATE i_lips-waybill t_line-tdline INTO i_lips-waybill.
ENDLOOP.
IF sy-subrc EQ 0.
MODIFY i_lips.
ENDIF.
ENDLOOP.
*IF i_report[] IS NOT INITIAL.
REFRESH it_report.
it_report[] = i_report[].
SORT it_report BY aubel.
DELETE ADJACENT DUPLICATES FROM it_report COMPARING aubel.
SELECT a~vbeln
b~name1
b~kunnr
b~regio
b~land1
a~vkgrp
b~niels
b~kukla
b~brsch
a~vkbur
FROM vbak AS a
INNER JOIN kna1 AS b
ON akunnr = bkunnr
INTO TABLE i_kna1
FOR ALL ENTRIES IN i_report
WHERE vbeln = i_report-aubel.
AND land1 = 'IN'.
*endif.
DATA : it_kna1 LIKE LINE OF i_kna1 OCCURS 0.
IF NOT i_kna1[] IS INITIAL.
REFRESH it_kna1.
it_kna1[] = i_kna1[].
SORT it_kna1 BY regio.
DELETE ADJACENT DUPLICATES FROM it_kna1 COMPARING regio.
SELECT spras
land1
bland
bezei FROM t005u
INTO TABLE i_t005u
FOR ALL ENTRIES IN it_kna1
WHERE bland = it_kna1-regio
AND spras = 'EN' AND land1 = 'IN'.
REFRESH it_kna1.
it_kna1[] = i_kna1[].
SORT it_kna1 BY niels.
DELETE ADJACENT DUPLICATES FROM it_kna1 COMPARING niels.
SELECT spras niels bezei FROM tnlst
INTO TABLE i_tnlst
FOR ALL ENTRIES IN it_kna1
WHERE niels = it_kna1-niels
AND spras = sy-langu.
REFRESH it_kna1.
it_kna1[] = i_kna1[].
SORT it_kna1 BY kukla.
DELETE ADJACENT DUPLICATES FROM it_kna1 COMPARING kukla.
SELECT spras kukla vtext FROM tkukt
INTO TABLE itab_tkukt
FOR ALL ENTRIES IN it_kna1
WHERE kukla = it_kna1-kukla
AND spras = sy-langu.
REFRESH it_kna1.
it_kna1[] = i_kna1[].
SORT it_kna1 BY brsch.
DELETE ADJACENT DUPLICATES FROM it_kna1 COMPARING brsch.
SELECT spras brsch brtxt FROM t016t
INTO TABLE itab_t016t
FOR ALL ENTRIES IN it_kna1
WHERE brsch = it_kna1-brsch
AND spras = sy-langu.
REFRESH it_kna1.
it_kna1[] = i_kna1[].
SORT it_kna1 BY vkgrp.
DELETE ADJACENT DUPLICATES FROM it_kna1 COMPARING vkgrp.
SELECT spras vkgrp bezei FROM tvgrt
INTO TABLE itab_tvgrt
FOR ALL ENTRIES IN it_kna1
WHERE vkgrp = it_kna1-vkgrp
AND spras = sy-langu.
ENDIF.
SORT i_kna1 BY vbeln ASCENDING.
IF i_report[] IS NOT INITIAL.
REFRESH it_report.
it_report[] = i_report[].
SORT it_report BY aubel.
DELETE ADJACENT DUPLICATES FROM it_report COMPARING aubel.
SELECT a~vbeln
a~kunnr
b~city1
FROM vbpa AS a
INNER JOIN adrc AS b
ON aadrnr = baddrnumber
INTO TABLE i_adrc
FOR ALL ENTRIES IN it_report
WHERE vbeln = it_report-aubel
AND parvw = 'WE'.
SORT i_adrc BY vbeln ASCENDING.
ENDIF.
DATA : it_adrc LIKE LINE OF i_adrc OCCURS 0.
IF i_adrc[] IS NOT INITIAL.
REFRESH it_adrc.
it_adrc[] = i_adrc[].
SORT it_adrc BY kunnr.
DELETE ADJACENT DUPLICATES FROM it_adrc COMPARING kunnr.
SELECT kunnr name1
FROM kna1
INTO TABLE i_kna2
FOR ALL ENTRIES IN it_adrc
WHERE kunnr = it_adrc-kunnr.
ENDIF.
SELECT a~lifnr
a~vbeln
b~name1
FROM vbpa AS a
INNER JOIN lfa1 AS b
ON alifnr = blifnr
INTO TABLE i_lfa1
FOR ALL ENTRIES IN i_report
WHERE vbeln = i_report-vgbel
AND parvw = 'SP'.
SORT i_lfa1 BY vbeln ASCENDING.
change amit by my self may be removed
IF i_report[] IS NOT INITIAL.
REFRESH it_report.
it_report[] = i_report[].
SORT it_report BY vbeln.
DELETE ADJACENT DUPLICATES FROM it_report COMPARING vbeln.
SELECT exnum
exdat
rdoc
status
FROM j_1iexchdr
INTO TABLE itab_exnum
FOR ALL ENTRIES IN it_report
WHERE rdoc = it_report-vbeln AND status = 'P' OR status = 'C' .
ENDIF.
change amit by my self may be removed
change amit by my self may be removed
IF i_report[] IS NOT INITIAL.
REFRESH it_report.
it_report[] = i_report[].
SORT it_report BY aubel.
DELETE ADJACENT DUPLICATES FROM it_report COMPARING aubel.
SELECT kwmeng
vbeln
lgort
FROM vbap
INTO TABLE itab_qty
FOR ALL ENTRIES IN it_report
WHERE vbeln = it_report-aubel.
ENDIF.
change amit by my self may be removed
SORT itab_qty BY vbeln.
CHECK NOT i_vbrk[] IS INITIAL.
SORT i_report BY vbeln.
DATA : t_vbrk LIKE LINE OF i_vbrk OCCURS 0.
REFRESH t_vbrk.
t_vbrk[] = i_vbrk[].
SORT t_vbrk BY knumv.
DELETE ADJACENT DUPLICATES FROM t_vbrk COMPARING knumv.
SELECT ksteu
knumv
kschl
kbetr
kwert
kposn
kmein
FROM konv
INTO TABLE it_rate
FOR ALL ENTRIES IN t_vbrk
WHERE knumv = t_vbrk-knumv
AND kschl IN ('ZR00', "Basic Price
'ZR01', "Basic Price
'ZR02', "Basic Price
'ZR03', "Basic Price
'ZR04', "Basic Price
'ZR05', "Basic Price
'JEXP', "Excise
'JECS', "ED
'ZG03', "Freight
'ZG04', "Freight
'JCST', "CST
'JLST', "LST
'ZDEV', "Dev Tax
'Z001', "Discount
'Z002', "Discount
'Z003', "Discount
'Z004', "Discount
'Z005', "Discount
'Z006', "Discount
'Z007', "Discount -
Short dump due termination in the program SAPLSNR3
Hi Experts,
While running an IP I am getting short dump, and error analysis says
An ASSIGN statement in the program "SAPLSNR3" contained a field symbol with
length 0. This is not possible. length 0.This is not possible.
can any one exlain why the IP is going for short dump,rectify the error and make the IP to run sucessful.
Regards,
SiddhardhHi Suresh,
Your dump is occuring due to database limit of sql statment (Native SQL) that is generated from your abap sql. The range is killing him (as you already notice).
The thread bellow have some info about this, but the solution can't be applyed to you:
To update 1 field of ztable(60 fields) for 2000 records in minimum DB hit
Maybe you can build some logic to reduce the value of two ranges (also concatenating them). Anyway, due to amount of lines involved (24.500 lines).... I don't think it is possible.
One option is filter the result on ABAP, after your SQL w/o the ranges you may try:
DELETE FROM TABLE i_glpct2
WHERE NOT ( racct IN r_profloss OR racct IN r_balsheet ).
This can raise a performance problem if the number of returned rows from database is to high.
Another option is change your database access. Where the values of the two ranges came from ? database ? If they came from database try to use INNER JOIN, this will solve the problem w/o performance problem.
Best Regards, Fernando Da Ró -
Hi,
please correct me where i went wrong...
RANGES: r_daterange FOR vbak-audat.
RANGES:GRG_DATERANGE FOR VBAK-AUDAT.
PERFORM CHECK_SELECT_OPTIONS USING DATE_FROM
DATE_TO
CHANGING R_DATERANGE[].
if sales order number is the selection criteria
if not salesorder_no is initial.
clear :wa_vbak, wa_vbfa, wa_costlist_in.
refresh:t_vbak, costlist_in.
select avbeln aauart bposnr bnetpr
into table t_vbak
from vbak as a
inner join vbap as b
on avbeln = bvbeln
where a~vbeln = salesorder_no
and a~audat in r_daterange
and a~kunnr = partner_number
and b~abgru NE ' ' .
***INCLUDE /VWNA/LINSD_BAPI_INV_GET_INF01 .
*& Form CHECK_SELECT_OPTIONS
text
-->P_DATE_FROM text
-->P_DATE_TO text
<--P_R_DATERANGE[] text
FORM CHECK_SELECT_OPTIONS USING P_DATE_FROM LIKE VBAK-AUDAT
P_DATE_TO LIKE VBAK-AUDAT
CHANGING PRG_DATERANGE LIKE GRG_DATERANGE[].
DATA: WA_DATERANGE LIKE GRG_DATERANGE.
CLEAR WA_DATERANGE.
REFRESH PRG_DATERANGE.
WA_DATERANGE-SIGN = 'I'.
iF ( P_DATE_FROM IS INITIAL ) AND ( P_DATE_TO IS INITIAL ).
ELSEIF P_DATE_FROM IS INITIAL.
WA_DATERANGE-OPTION = 'LE'.
MOVE P_DATE_TO TO WA_DATERANGE-LOW.
ELSEIF P_DATE_TO IS INITIAL.
WA_DATERANGE-OPTION = 'GE'.
MOVE P_DATE_FROM TO WA_DATERANGE-LOW.
ELSE.
WA_DATERANGE-OPTION = 'BT'.
MOVE P_DATE_FROM TO WA_DATERANGE-LOW.
MOVE P_DATE_TO TO WA_DATERANGE-HIGH.
ENDIF.
APPEND WA_DATERANGE TO PRG_DATERANGE.
clear wa_daterange.
When i execute the code its creating a short dump and the message is :
The current ABAP/4 program attempted to execute an ABAP/4 Open SQL
statement in which the WHERE condition contains an IN itab operator.
The IN itab operator is used with internal tables which
have the following structure:
SIGN(1) OPTION(2) LOW LIKE db_field HIGH LIKE db_field
The OPTION column should contain only one of the following values:
"EQ LE GE CP BT NE LT GT NP NB"
The value " " is not allowed here. Please help me in resolving the error..
Thanks,
ChallaHi
This will happen when P_DATE_FROM IS INITIAL AND P_DATE_TO IS INITIAL.
You are populating the range table with just sign as 'I' and option is not populated.
change your code to:
WA_DATERANGE-SIGN = 'I'.
iF ( P_DATE_FROM IS INITIAL ) AND ( P_DATE_TO IS INITIAL ).
ELSEIF P_DATE_FROM IS INITIAL.
WA_DATERANGE-OPTION = 'LE'.
MOVE P_DATE_TO TO WA_DATERANGE-LOW.
APPEND WA_DATERANGE TO PRG_DATERANGE.
ELSEIF P_DATE_TO IS INITIAL.
WA_DATERANGE-OPTION = 'GE'.
MOVE P_DATE_FROM TO WA_DATERANGE-LOW.
APPEND WA_DATERANGE TO PRG_DATERANGE.
ELSE.
WA_DATERANGE-OPTION = 'BT'.
MOVE P_DATE_FROM TO WA_DATERANGE-LOW.
MOVE P_DATE_TO TO WA_DATERANGE-HIGH.
APPEND WA_DATERANGE TO PRG_DATERANGE.
ENDIF.
*APPEND WA_DATERANGE TO PRG_DATERANGE.
clear wa_daterange.
Regards
Navneet -
Hi
The runtime error is DBIF_RSQL_INVALID_RSQL and the exception is CX_SY_OPEN_SQL_DB.can anyone explain me these errors.
At this select query it going to short dump.Could anyone help me.Its urgent.
Select aaufnr agstrp agsuzp biedd b~iedz into table i_uncount
from afko as a inner join afru as b on aaufnr = baufnr
for all entries in i_ordscp
where aaufnr = i_ordscp-aufnr and bgrund = 'ONS'
and b~stzhl = '0000000'.
Error Analysis:
The data read during a SELECT access could not be inserted into the target field.
Either the conversion is not supported for the target field's type or the target field is too short to accept the value or the data are not in a form that the target field can accept.
The target field is all correct.I've checked it.
Could anyone please help me.Its really urgent.U'll definitely be given points.
Thanks
chandrika.Hi Sarath ,
Please look at the internal table decleration and the sequence of fields in select statement .
What is happening is that the select is tying to place the value of iedd into aufpl as a result of which this incompatibilty occurs.
So you can either user into corresponding-fields or modify the sequence of your internal table.
I would sugges the second option , as first can effect the performance.
So just declare the it as
TYPES:BEGIN OF t_uncont,
aufnr like afko-aufnr,
gstrp like afko-gstrp,
gsuzp like afko-gsuzp,
iedd like afru-iedd,
iedz like afru-iedz,
aufpl like afko-aufpl,
END OF t_uncont.
Regards
Arun -
Short dump in reading selection values in Report
Hi all,
I have created a Navegational Attributte and added this Info Object in the existing Query and for this object we have created Charactistics Value Variable with Uesr Entry.
But, When we use input selection option to select a vlaue for this Variable in the Variable Selection Screen it is trying to read the values and going into short Dump but for other variables Selection option is working fine.
Please anyone help me if you have the solution.
Regards,
Ali.Hi,
Try deleting the master data and reload the master data again and check for the selection variables. Check the short dump in ST22 it will say which master table ie SID table or master table where the join fails.
Thanks,
Arun -
What is the purpose of short dump error report generated by the system? What r the major parts/section of this report?
hi please look through this:
Whenever any transaction or any process is executed it hits an ABAP code.
If there is any issue in executing the code the situation is called "ABAP DUMP" or 'Short Dump'
Transaction ST22 is used to check any ABAP Dump within a given duration.
U can also fix the issue with the help of ABAP editor (Transaction Code SE38) if u r good with ABAP.
you can select back to the last 14 days if you are
running the SAP_REORG_ABAPDUMPS job (program RSSNAPDL) which deletes te
old ABAP dumps every day, possibly further if you run it weekly or
monthly.
sap-basis sap-basisAll Groups Ignore this text box. It is used to detect spammers.If you enter anything into this text box, no search results will be displayed.
SAP Groups > Technical-functional > sap-basis > Message
About This Group | Invite peers to join this group
<< Prev thread < Prev msg Next msg > Next thread >>
short dump----urgent
Reply from Keith Lewis on 5/2/2003 3:22:00 AM
Good explanation Joy, but it is not only limited to the current day and
yesterday. If you click on the Selection button you can select previous
days as well. In fact you can select back to the last 14 days if you are
running the SAP_REORG_ABAPDUMPS job (program RSSNAPDL) which deletes te
old ABAP dumps every day, possibly further if you run it weekly or
monthly.
Cheers
Keith
SAP R/3 Support Specialist
Information Services International
Tel +44 1664 41 6178 Mobile +44 7887 627818
E-mail email@removed
Archive Page - http://www.ittoolbox.com//I/sap-r3-basis.asp
Dear sreenivas
If you receive an error message in the R/3 System log (SM21), or if you
see
a terminated update in the update service analysis transaction (SM13), or
DB
realated error ,check for dumps using the dump analysis transaction
(transaction ST22), or choose Tools -> Administration -> Monitoring ->
Dump
analysis.
Transaction ST22 enables you to analyze short dumps from the current and
previous day.
The dump analysis function shows you:
What happened
What you can do
How to correct the error
The dump analysis function also provides an error ID and keywords that you
can use to search in SAPNet, as well as information about:
The system environment
Users and transactions
Transaction ST22 enables you to analyze the following data:
Date, time, user, client
Contents of system and data fields
Contents of internal tables and application tables
ST22 is a very nice feature in SAP. This is where all the system errors
and users mistakes showed up. If there is a problem that you cannot
solve and you contact SAP support, they look at this area to analyze it.
This gives us lead where to handle the problems.
Error analysis
How to correct the error
System environment
User, transaction...
Information on where termination occurred
Contents of system fields
Chosen variables
Active calls / events
Internal notes
Active calls in SAP kernel
List of ABAP programs affected
List of internal tables
Directory of application tables (contents)
Directory of data areas (administration information)
Directory of data areas (contents)
ABAP control blocks CONT
End of runtime analysis
i think this would be helpful
regards
sravani -
How to deal with Short dump that restarts the index server?
Hi ,
I have been experiencing this problem whenever any exception occurs in my SQL SCRIPT procedure. For instance when there is a situation when I try to insert a value of 50 characters in length to a column with max size of 40 it throws a short dump and restarts the index server. I tried to insert the exception handling code as well but still the problem persists. Is there a way to solve this issue?Hi Sudarshan
crashes are rather generic reactions of the system to virtually any kind of problem that may occur.
Memory shortage is one of the more common issues in current SAP HANA setups and SAP HANA development is heavily working on handling memory shortage situations more gracefully.
Massive over allocation of memory, for example by very large intermediate result sets or join result sets typically can be addressed by correcting the query or model that leads to the issue.
Anyhow, the initial post was not about a memory shortage but about a crash that seemed to have occurred with wrong data type handling.
These are two very different kinds of problems, so I am not really sure how your comment relates here.
- Lars -
Very Slow Query with CTE inner join
I have 2 tables (heavily simplified here to show relevant columns):
CREATE TABLE tblCharge
(ChargeID int NOT NULL,
ParentChargeID int NULL,
ChargeName varchar(200) NULL)
CREATE TABLE tblChargeShare
(ChargeShareID int NOT NULL,
ChargeID int NOT NULL,
TotalAmount money NOT NULL,
TaxAmount money NULL,
DiscountAmount money NULL,
CustomerID int NOT NULL,
ChargeShareStatusID int NOT NULL)
I have a very basic View to Join them:
CREATE VIEW vwBASEChargeShareRelation as
Select c.ChargeID, ParentChargeID, s.CustomerID, s.TotalAmount, isnull(s.TaxAmount, 0) as TaxAmount, isnull(s.DiscountAmount, 0) as DiscountAmount
from tblCharge c inner join tblChargeShare s
on c.ChargeID = s.ChargeID Where s.ChargeShareStatusID < 3
GO
I then have a view containing a CTE to get the children of the Parent Charge:
ALTER VIEW [vwChargeShareSubCharges] AS
WITH RCTE AS
SELECT ParentChargeId, ChargeID, 1 AS Lvl, ISNULL(TotalAmount, 0) as TotalAmount, ISNULL(TaxAmount, 0) as TaxAmount,
ISNULL(DiscountAmount, 0) as DiscountAmount, CustomerID, ChargeID as MasterChargeID
FROM vwBASEChargeShareRelation Where ParentChargeID is NULL
UNION ALL
SELECT rh.ParentChargeID, rh.ChargeID, Lvl+1 AS Lvl, ISNULL(rh.TotalAmount, 0), ISNULL(rh.TaxAmount, 0), ISNULL(rh.DiscountAmount, 0) , rh.CustomerID
, rc.MasterChargeID
FROM vwBASEChargeShareRelation rh
INNER JOIN RCTE rc ON rh.PArentChargeID = rc.ChargeID and rh.CustomerID = rc.CustomerID
Select MasterChargeID as ChargeID, CustomerID, Sum(TotalAmount) as TotalCharged, Sum(TaxAmount) as TotalTax, Sum(DiscountAmount) as TotalDiscount
from RCTE
Group by MasterChargeID, CustomerID
GO
So far so good, I can query this view and get the total cost for a line item including all children.
The problem occurs when I join this table. The query:
Select t.* from vwChargeShareSubCharges t
inner join
tblChargeShare s
on t.CustomerID = s.CustomerID
and t.MasterChargeID = s.ChargeID
Where s.ChargeID = 1291094
Takes around 30 ms to return a result (tblCharge and Charge Share have around 3.5 million records).
But the query:
Select t.* from vwChargeShareSubCharges t
inner join
tblChargeShare s
on t.CustomerID = s.CustomerID
and t.MasterChargeID = s.ChargeID
Where InvoiceID = 1045854
Takes around 2 minutes to return a result - even though the only charge with that InvoiceID is the same charge as the one used in the previous query.
The same thing occurs if I do the join in the same query that the CTE is defined in.
I ran the execution plan for each query. The first (fast) query looks like this:
The second(slow) query looks like this:
I am at a loss, and my skills at decoding execution plans to resolve this are lacking.
I have separate indexes on tblCharge.ChargeID, tblCharge.ParentChargeID, tblChargeShare.ChargeID, tblChargeShare.InvoiceID, tblChargeShare.ChargeShareStatusID
Any ideas? Tested on SQL 2008R2 and SQL 2012>> The database is linked [sic] to an established app and the column and table names can't be changed. <<
Link? That is a term from pointer chains and network databases, not SQL. I will guess that means the app came back in the old pre-RDBMS days and you are screwed.
>> I am not too worried about the money field [sic], this is used for money and money based calculations so the precision and rounding are acceptable at this level. <<
Field is a COBOL concept; columns are totally different. MONEY is how Sybase mimics the PICTURE clause that puts currency signs, commas, period, etc in a COBOL money field.
Using more than one operation (multiplication or division) on money columns will produce severe rounding errors. A simple way to visualize money arithmetic is to place a ROUND() function calls after
every operation. For example,
Amount = (Portion / total_amt) * gross_amt
can be rewritten using money arithmetic as:
Amount = ROUND(ROUND(Portion/total_amt, 4) *
gross_amt, 4)
Rounding to four decimal places might not seem an
issue, until the numbers you are using are greater
than 10,000.
BEGIN
DECLARE @gross_amt MONEY,
@total_amt MONEY,
@my_part MONEY,
@money_result MONEY,
@float_result FLOAT,
@all_floats FLOAT;
SET @gross_amt = 55294.72;
SET @total_amt = 7328.75;
SET @my_part = 1793.33;
SET @money_result = (@my_part / @total_amt) *
@gross_amt;
SET @float_result = (@my_part / @total_amt) *
@gross_amt;
SET @Retult3 = (CAST(@my_part AS FLOAT)
/ CAST( @total_amt AS FLOAT))
* CAST(FLOAT, @gross_amt AS FLOAT);
SELECT @money_result, @float_result, @all_floats;
END;
@money_result = 13525.09 -- incorrect
@float_result = 13525.0885 -- incorrect
@all_floats = 13530.5038673171 -- correct, with a -
5.42 error
>> The keys are ChargeID(int, identity) and ChargeShareID(int, identity). <<
Sorry, but IDENTITY is not relational and cannot be a key by definition. But it sure works just like a record number in your old COBOL file system.
>> .. these need to be int so that they are assigned by the database and unique. <<
No, the data type of a key is not determined by physical storage, but by logical design. IDENTITY is the number of a parking space in a garage; a VIN is how you identify the automobile.
>> What would you recommend I use as keys? <<
I do not know. I have no specs and without that, I cannot pull a Kabbalah number from the hardware. Your magic numbers can identify Squids, Automobile or Lady Gaga! I would ask the accounting department how they identify a charge.
>> Charge_Share_Status_ID links [sic] to another table which contains the name, formatting [sic] and other information [sic] or a charge share's status, so it is both an Id and a status. <<
More pointer chains! Formatting? Unh? In RDBMS, we use a tiered architecture. That means display formatting is in a presentation layer. A properly created table has cohesion – it does one and only one data element. A status is a state of being that applies
to an entity over a period time (think employment, marriage, etc. status if that is too abstract).
An identifier is based on the Law of Identity from formal logic “To be is to be something in particular” or “A is A” informally. There is no entity here! The Charge_Share_Status table should have the encoded values for a status and perhaps a description if
they are unclear. If the list of values is clear, short and static, then use a CHECK() constraint.
On a scale from 1 to 10, what color is your favorite letter of the alphabet? Yes, this is literally that silly and wrong.
>> I understand what a CTE is; is there a better way to sum all children for a parent hierarchy? <<
There are many ways to represent a tree or hierarchy in SQL. This is called an adjacency list model and it looks like this:
CREATE TABLE OrgChart
(emp_name CHAR(10) NOT NULL PRIMARY KEY,
boss_emp_name CHAR(10) REFERENCES OrgChart(emp_name),
salary_amt DECIMAL(6,2) DEFAULT 100.00 NOT NULL,
<< horrible cycle constraints >>);
OrgChart
emp_name boss_emp_name salary_amt
==============================
'Albert' NULL 1000.00
'Bert' 'Albert' 900.00
'Chuck' 'Albert' 900.00
'Donna' 'Chuck' 800.00
'Eddie' 'Chuck' 700.00
'Fred' 'Chuck' 600.00
This approach will wind up with really ugly code -- CTEs hiding recursive procedures, horrible cycle prevention code, etc. The root of your problem is not knowing that rows are not records, that SQL uses sets and trying to fake pointer chains with some
vague, magical non-relational "id".
This matches the way we did it in old file systems with pointer chains. Non-RDBMS programmers are comfortable with it because it looks familiar -- it looks like records and not rows.
Another way of representing trees is to show them as nested sets.
Since SQL is a set oriented language, this is a better model than the usual adjacency list approach you see in most text books. Let us define a simple OrgChart table like this.
CREATE TABLE OrgChart
(emp_name CHAR(10) NOT NULL PRIMARY KEY,
lft INTEGER NOT NULL UNIQUE CHECK (lft > 0),
rgt INTEGER NOT NULL UNIQUE CHECK (rgt > 1),
CONSTRAINT order_okay CHECK (lft < rgt));
OrgChart
emp_name lft rgt
======================
'Albert' 1 12
'Bert' 2 3
'Chuck' 4 11
'Donna' 5 6
'Eddie' 7 8
'Fred' 9 10
The (lft, rgt) pairs are like tags in a mark-up language, or parens in algebra, BEGIN-END blocks in Algol-family programming languages, etc. -- they bracket a sub-set. This is a set-oriented approach to trees in a set-oriented language.
The organizational chart would look like this as a directed graph:
Albert (1, 12)
Bert (2, 3) Chuck (4, 11)
/ | \
/ | \
/ | \
/ | \
Donna (5, 6) Eddie (7, 8) Fred (9, 10)
The adjacency list table is denormalized in several ways. We are modeling both the Personnel and the Organizational chart in one table. But for the sake of saving space, pretend that the names are job titles and that we have another table which describes the
Personnel that hold those positions.
Another problem with the adjacency list model is that the boss_emp_name and employee columns are the same kind of thing (i.e. identifiers of personnel), and therefore should be shown in only one column in a normalized table. To prove that this is not
normalized, assume that "Chuck" changes his name to "Charles"; you have to change his name in both columns and several places. The defining characteristic of a normalized table is that you have one fact, one place, one time.
The final problem is that the adjacency list model does not model subordination. Authority flows downhill in a hierarchy, but If I fire Chuck, I disconnect all of his subordinates from Albert. There are situations (i.e. water pipes) where this is true, but
that is not the expected situation in this case.
To show a tree as nested sets, replace the nodes with ovals, and then nest subordinate ovals inside each other. The root will be the largest oval and will contain every other node. The leaf nodes will be the innermost ovals with nothing else inside them
and the nesting will show the hierarchical relationship. The (lft, rgt) columns (I cannot use the reserved words LEFT and RIGHT in SQL) are what show the nesting. This is like XML, HTML or parentheses.
At this point, the boss_emp_name column is both redundant and denormalized, so it can be dropped. Also, note that the tree structure can be kept in one table and all the information about a node can be put in a second table and they can be joined on employee
number for queries.
To convert the graph into a nested sets model think of a little worm crawling along the tree. The worm starts at the top, the root, makes a complete trip around the tree. When he comes to a node, he puts a number in the cell on the side that he is visiting
and increments his counter. Each node will get two numbers, one of the right side and one for the left. Computer Science majors will recognize this as a modified preorder tree traversal algorithm. Finally, drop the unneeded OrgChart.boss_emp_name column
which used to represent the edges of a graph.
This has some predictable results that we can use for building queries. The root is always (left = 1, right = 2 * (SELECT COUNT(*) FROM TreeTable)); leaf nodes always have (left + 1 = right); subtrees are defined by the BETWEEN predicate; etc. Here are
two common queries which can be used to build others:
1. An employee and all their Supervisors, no matter how deep the tree.
SELECT O2.*
FROM OrgChart AS O1, OrgChart AS O2
WHERE O1.lft BETWEEN O2.lft AND O2.rgt
AND O1.emp_name = :in_emp_name;
2. The employee and all their subordinates. There is a nice symmetry here.
SELECT O1.*
FROM OrgChart AS O1, OrgChart AS O2
WHERE O1.lft BETWEEN O2.lft AND O2.rgt
AND O2.emp_name = :in_emp_name;
3. Add a GROUP BY and aggregate functions to these basic queries and you have hierarchical reports. For example, the total salaries which each employee controls:
SELECT O2.emp_name, SUM(S1.salary_amt)
FROM OrgChart AS O1, OrgChart AS O2,
Salaries AS S1
WHERE O1.lft BETWEEN O2.lft AND O2.rgt
AND S1.emp_name = O2.emp_name
GROUP BY O2.emp_name;
4. To find the level and the size of the subtree rooted at each emp_name, so you can print the tree as an indented listing.
SELECT O1.emp_name,
SUM(CASE WHEN O2.lft BETWEEN O1.lft AND O1.rgt
THEN O2.sale_amt ELSE 0.00 END) AS sale_amt_tot,
SUM(CASE WHEN O2.lft BETWEEN O1.lft AND O1.rgt
THEN 1 ELSE 0 END) AS subtree_size,
SUM(CASE WHEN O1.lft BETWEEN O2.lft AND O2.rgt
THEN 1 ELSE 0 END) AS lvl
FROM OrgChart AS O1, OrgChart AS O2
GROUP BY O1.emp_name;
5. The nested set model has an implied ordering of siblings which the adjacency list model does not. To insert a new node, G1, under part G. We can insert one node at a time like this:
BEGIN ATOMIC
DECLARE rightmost_spread INTEGER;
SET rightmost_spread
= (SELECT rgt
FROM Frammis
WHERE part = 'G');
UPDATE Frammis
SET lft = CASE WHEN lft > rightmost_spread
THEN lft + 2
ELSE lft END,
rgt = CASE WHEN rgt >= rightmost_spread
THEN rgt + 2
ELSE rgt END
WHERE rgt >= rightmost_spread;
INSERT INTO Frammis (part, lft, rgt)
VALUES ('G1', rightmost_spread, (rightmost_spread + 1));
COMMIT WORK;
END;
The idea is to spread the (lft, rgt) numbers after the youngest child of the parent, G in this case, over by two to make room for the new addition, G1. This procedure will add the new node to the rightmost child position, which helps to preserve the idea
of an age order among the siblings.
6. To convert a nested sets model into an adjacency list model:
SELECT B.emp_name AS boss_emp_name, E.emp_name
FROM OrgChart AS E
LEFT OUTER JOIN
OrgChart AS B
ON B.lft
= (SELECT MAX(lft)
FROM OrgChart AS S
WHERE E.lft > S.lft
AND E.lft < S.rgt);
7. To find the immediate parent of a node:
SELECT MAX(P2.lft), MIN(P2.rgt)
FROM Personnel AS P1, Personnel AS P2
WHERE P1.lft BETWEEN P2.lft AND P2.rgt
AND P1.emp_name = @my_emp_name;
I have a book on TREES & HIERARCHIES IN SQL which you can get at Amazon.com right now. It has a lot of other programming idioms for nested sets, like levels, structural comparisons, re-arrangement procedures, etc.
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
hi all,
i am facing the problem with the inner join in the select query for 4 tables.
can i use the inner join for tables in SAP 6.0 version,
it is going to dump.
here is my code
SELECT DISTINCT apernr abegda aendda awagetype aamount acurrency
altrctry brufnm banred bvorna bnachn cgroupcode d~vdsk1
FROM pa9011 AS a INNER JOIN pa0002 AS b ON bpernr = apernr
INNER JOIN pa9013 AS c ON cpernr = bpernr
inner join pa0001 as d on dpernr = cpernr
INTO CORRESPONDING FIELDS OF TABLE it_bonus
WHERE a~pernr IN s_pernr AND
a~begda IN s_date AND
a~subty EQ s_subty AND
a~wagetype EQ wa_perbonus AND
a~ltrctry = gc_ind AND
a~amount > 0 AND
b~endda = '99991231' AND
c~groupcode IN s_loc AND
c~endda = '99991231' and
d~endda = '99991231'
ORDER BY a~pernr.hi this is the dump ,
In a SELECT access, the read file could not be placed in the target
field provided.
Either the conversion is not supported for the type of the target field,
the target field is too small to include the value, or the data does not
have the format required for the target field. -
Performance in Inner Join on VBAK
HI,
For a customized report the select statement was written like this which is giving time out error for large data. How one can improve performance of following Inner Joins.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE it_tab
FROM vbak as A INNER JOIN vbuk as B
ON Avbeln = Bvbeln
INNER JOIN vbkd as C
ON Avbeln = Cvbeln
WHERE A~vbeln IN so_vbeln
AND A~audat IN so_audat
AND A~auart IN so_auart
AND A~augru IN so_augru
AND A~faksk IN so_faksp
AND A~vkorg IN so_vkorg
AND A~vtweg IN so_vtweg
AND A~spart IN so_spart
AND A~vkbur IN so_vkbur
AND A~vkgrp IN so_vkgrp
AND A~vsbed IN so_vsbed
AND A~kunnr IN so_kunnr
and B~gbstk IN so_gbstx
AND C~posnr = '000000'.
Thanks
anya
Moderator message: FAQ, it all depends on the content of the so_ ranges at runtime.
Please Read before Posting in the Performance and Tuning Forum
Edited by: Thomas Zloch on Nov 1, 2010 11:57 AMOthers have already responded, and I would only like to dwell on the answers for a short while. Or maybe rather the question.
This question is typical for the inexperienced developer. This particular question is actually a little different, because there is a straight answer: there is no difference. For most questions of this type the answer is "it depends", because one
particular syntax can happen to perform better with one set of data and indexes, but with a different data/index profile another syntax gives better result.
Ideally, as long as two queries are logically equivalent, the syntax should not matter at all, because the optimizer should always figure out the best way to achieve the result. In practice, this is not the case, because there are lots of limitaitons in
an optimizer in an RDBMS.
While it certainly can matter for performance how you write your queries, that is not what you should focus on. What you should focus is to express your query as clearly as possible, and make sure that you have the relevant indexes in place. There is one
rule when it comes to query-writing you should take your heart: never entable a column in a condition in an expression, because that is likely to render index on that column useless.
For this particular question, the answer is that as you long as you write code for SQL Server, use the JOIN syntax. But if you use that in the Oracle world, you may get funny looks from people. It's a different culture over there...
Erland Sommarskog, SQL Server MVP, [email protected] -
HI EXPERTS,
I've got a short dump to handle.
When my functional consultant goes to:
Transaction SPRO->clicks on SAP REFERENCE IMG->clicks on FIND button-> enters "FUNDS MANAGEMENT" as search term.->then when he clicks on any of the result of the displayed hit list he gets the following dump.
ERROR:
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SYNTAX', was not
caught in
procedure "STREE_READ_NODE_GENER" "(FUNCTION)", nor was it propagated by a
RAISING clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
The running ABAP program attempted to execute an Open SQL statement in
which a FROM clause was specified dynamically in the field "TABLE_NAME". In
this
FROM clause, either a table name after a join operator is missing, or an
alias name after the key name "AS". The field "TABLE_NAME" could be empty as
well.
HOW SHOULD I GO ABOUT IT.
PLEASE HELP.
ITS URGENT.
THANKS.If it is an standard SAP App...You should create an OSS Note.
If the short dump is on a custom App, you should use TRY - CATCH keywords.
Greetings,
Blag.
Maybe you are looking for
-
How do I take over contacts from other phone?
3GS, 3.1, Windows 7 Trial version My wife and I both have a 3GS. For some reason my contacts have disappeared after I upgraded to 3.1. Most of my wife's contacts are the same as mine. Instead of having to enter everything again I would like to take o
-
Top Link error 17002 The Network Adapter could not establish the connection
I have installed an application developped in an another environnement. I have created the database schema in my own database. I have created a database connection to this schema. I have reconciled the schema using this connection (so the database an
-
ORA-01031: insufficient privileges While trying / as sysdba
I have an Oracle user (jjcdba) through which I login to the database. From today morning, I am unable to login to the database and I am getting this error. $=> id uid=123(jjcdba) gid=3203(jjcdba) [jjcdba@jjcprd04:/jjc/orasw10/oracle/product/10.2.4] $
-
Drawing artifacts with motion under a gradient mask
Hello, I am having an issue with using a motion under a gradient mask and was hoping someone might have a solution. I have a transparent png bubble in movie clips that are being randomly sized and animation started using code. The design has a refl
-
Check CRM Error Flag of Workflow Condition in own Code Condition
Hi everybody, I am creating an own condition with the help of a badi. Can any body tell me how to check if a ticket has an error message like the CRM Error Flag in the Work Flow Condition`? Regards Ali