SQVI: Joining Different Field Names
Hey all,
Is it possible to join two fields that are not of the exact same technical name?
We are trying to join tables KSSK and WLK1. We want to link the assortment (FILIA in WLK1) to the assortment object (OBJEK in KSSK).
Would this be possible?
Thank you,
Ryan
Well...WLK1 is empty on my system, so it's hard to tell...
Maybe I will do it like this...Select data from KSSK first, and the LOOP it taking only 10 characters from field OBJEK...For each iteration of the LOOP I will do a SELECT SINGLE of WLK1...If there's no data, then that registry should be gone...and so on...
Of course, not the best solution...But can't seem to find anything else...
Greetings,
Blag.
Similar Messages
-
IDoc: E1EDL44 2 contains different field names in segments
Our client picks up delivery data sent over EDI and a Middleware program to put it in a form.
The Middleware picks up the customer material number from KDMAT of the HU data.
For 1 particular material X KDMAT is not available in the idoc record E1EDL44 2.
With not available I mean KDMAT is not in the list of field names.
This leads to inconsistencies on our client's form for which we are penalized.
For material Y in the same record E1EDL44 2 (different segment) KDMAT is available.
This one is populating correctly on the client's form.
I checked VD52 for material X and there exist an entry for KDMAT.
What more do I need to analyze?
How do I solve this issue?
Best regards,
GeertHi,
Are you talking about an outbound interface or inbound interface.
If it is an outbound interface, if the Customer Material number is maintained in VD52 transaction then it would automatically come into the IDOC, if it is not coming then check the FM and the corresponding user exit, some custom code would have cleared that value in the idoc segment.
Thanks,
Mahesh. -
Join different fields with same length in query (SQ02)
Hello,
Although i looked up all titles, i couldnt find a solution for my problem.
Im making a query for mara marc and mbew tables.
I joined these tables and i see the outputs, no problem by now.
But now i want to equalize mbew-bwkey and marc-werks.
both of these fields are char 4.
But when i try to join it from SQ02 i cant get correct result and i couldnt handle it from coding options either.
i will give an example about what i want :
the output i get :
150114 1011 202 FERT 010001000200020002 ELT 0010 ND 0201 001 EX 1011
150114 1011 202 FERT 010001000200020002 ELT 0010 ND 0201 001 EX 1013
150114 1011 202 FERT 010001000200020002 ELT 0010 ND 0201 001 EX 1031
150114 1011 202 FERT 010001000200020002 ELT 0010 ND 0201 001 EX 1032
150114 1011 202 FERT 010001000200020002 ELT 0010 ND 0201 001 EX 1033
150114 1011 202 FERT 010001000200020002 ELT 0010 ND 0201 001 EX 1034
the output i want to get: ( marc-werks(1011) = mbew-bwkey(1011) i dont want to see other results.
150114 1011 202 FERT 010001000200020002 ELT 0010 ND 0201 001 EX 1011
What do you suggest?
Thanks a lot.Thanks Tony for your reply. Here are my answers.
Are we talking a large amount of inserts?
YES
What is the autogrowth settings for the database files on the two Servers?
Autogrowth by 10%
The Server you are having an issue with, are the any triggers on the Tables?
No.
Is there a background or other trace running on the slow Server that could be impacting performance?
Yes, we are running a monitoring tool to check the performance of the load.
Is there another database on the slow Server causing issues?
No.
This could be a hardware issue; have you use perfmon to see if there are any disk queues?
We will check with our DBA on this.
What is the Raid Configuration? Are the files on a single spindle? If so what is the fragmentation state of any single spindle volume?
There is no Rain Configuration. Its a Windows Azure A7.
Are you automatically updating statistics on the slow Database?
Yes.
Is the Anti Virus Software on the Slow server scanning the data files?
Yes, but not on the database level.
Regards,
kranthi. -
Facing problem in getting data in different field
hi,
i have made a report in ALV format. n the whole code is this..
TABLES: VBAK,vbap.
type-pools: slis. "ALV Declarations
SELECT-OPTIONS:
s_sales for vbak-kunnr obligatory,
s_date for VBAK-audat obligatory.
*Data Declaration
types: begin of s_sales,
kunnr like vbak-kunnr,
ernam like VBRP-ernam,
audat like VBAK-audat,
aufnr like VBAK-aufnr,
KBMENG like vbap-KWMENG,
matnr like vbap-matnr,
matwa like vbap-matkl,
end of s_sales.
DATA: IT_VBAKUK TYPE STANDARD TABLE OF s_sales INITIAL SIZE 0,
WA_sales TYPE s_sales.
*ALV data declarations.
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid.
*start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform display_alv_report.
*& Form build_fieldcatalog
text
form build_fieldcatalog.
fieldcatalog-fieldname = 'KUNNR'.
fieldcatalog-seltext_m = 'Customer Code'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'ernam'.
fieldcatalog-seltext_m = 'Customer Name'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'stadat'.
fieldcatalog-seltext_m = 'Order Date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'aufnr'.
fieldcatalog-seltext_m = 'Order No'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'KWMENG'.
fieldcatalog-seltext_m = 'Quantity'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'matnr'.
fieldcatalog-seltext_m = 'Material Code'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'matkl'.
fieldcatalog-seltext_m = 'Material Description'.
fieldcatalog-col_pos = 7.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. "build_fieldcatalog
*& Form build_layout
text
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
endform. "build_layout
*& Form display_alv_report
text
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gd_repid
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
i_save = 'X'
TABLES
t_outtab = IT_VBAKUK
EXCEPTIONS
program_error = 1
others = 2.
if sy-subrc <> 0.
endif.
endform. " DISPLAY_ALV_REPORT
*& Form data_retrieval
text
form data_retrieval.
select vbakkunnr VBakernam VBAkaudat vbakaufnr vbapKWMENG vbapmatnr vbap~matkl
up to 10 rows
from vbak inner join vbap on vbakvbeln = vbapvbeln
into table IT_VBAKUK.
endform. "data_retrieval
When a execute this query it get this result:
Customer code Customer No. Order Date *Order No. * *Quantity * Material code Material Description
0000001390 0000001390 0000001390 0000001390 0000001390 0000001390 0000001390
0000001175 0000001175 0000001175 0000001175 0000001175 0000001175 0000001175
0000001175 0000001175 0000001175 0000001175 0000001175 0000001175 0000001175
0000001175 0000001175 0000001175 0000001175 0000001175 0000001175 0000001175
0000001175 0000001175 0000001175 0000001175 0000001175 0000001175 0000001175
0000001001 0000001001 0000001001 0000001001 0000001001 0000001001 0000001001
0000002200 0000002200 0000002200 0000002200 0000002200 0000002200 0000002200
0000002200 0000002200 0000002200 0000002200 0000002200 0000002200 0000002200
0000002200 0000002200 0000002200 0000002200 0000002200 0000002200 0000002200
0000002200 0000002200 0000002200 0000002200 0000002200 0000002200 0000002200
You can see in all column data is repeating even tough i have given different field name...
Kindly give me solution of this problem.
Thanks n Regards.hi,
i have these field:
*select VBAK~KUNNR VBAK~ERNAM VBAK~AUDAT VBAK~AUFNR VBAP~KWMENG VBAP~MATNR VBAP~MATKL
up to 10 rows
from VBAK inner join VBAP on VBAK~VBELN = VBAP~VBELN
into table IT_VBAKUK.
endform.*
I want to add these field in my parameter by using WHERE clause but don't know how to restrict these field using where clause.
Kindly give me some example related to this.
Regards -
Changing the field names in a CFQUERY object
Hello, I wonder whether you know the answer to this?
I want to change the names of the fields in a CFQUERY result
set after I have retrieved the results from the database (ie. I
can't use "AS" in the original SQL statement). I can think of 2
ways to do this - use the query-a-query (CFSQL) feature or just
build and populate a new query object, as set out below:
<cfquery name="CustList" datasource="name">
SELECT CustId,CustName,CustAddress FROM Customers
WHERE OrderStatus='P'
</cfquery>
OPTION#1:
<cfqueryname="GenericList" type="query">
SELECT CustId AS Id,CustName AS Name,CustAddress AS Address
FROM CustList
</cfquery>
OPTION#2:
<cfset GenericList = QueryNew("Id,Name,Address")>
<cfloop query="CustList">
<cfset unused = QueryAddRow(GenericList)>
<cfset unused =
QuerySetCell(GenericList,"Id",CustList.CustId)>
<cfset unused =
QuerySetCell(GenericList,"Name",CustList.CustName)>
<cfset unused =
QuerySetCell(GenericList,"Address",CustList.CustAddress)>
</cfloop>
Do you know which of these would be more efficient? And is
there a better way, whereby I can maniplulate the names of the
columns in the original query (ie. so that I can rename the
"CustName" field to "Name" and then use "CustList.Name" directly)?
Thanks!Thanks guys!
If there is a close to zero overhead to the simple
query-a-query then that seems like the way to go, with no need to
look for a means of manipulating or modifying the original query.
The reason I want to change the field names is so that the
rest of my code can contain references to "CustList.Name" whereas
otherwise I would have to do something like
"Evaluate('CustList.#NameField#')" which is horribly messy. And the
way the original query is generated means I can't use "AS" in it,
but I still want to use the same code to work with that query
result and other query results that share similar/related data with
different field names. -
Field name issues when spawning from template
I am currently spawning a template multiple times in my document (with the field names being changed), but I am NOT spawning them at the end. Rather, they all must get spawned to the same page. This results in every corresponding field on every spawned page having the same prefix, e.g. P1.template.field.
How can I avoid this? Also, is there any way to remove the prefix from just a few field names that I actually WANT to be the same?
Thanks!For your first question, can your provide a bit of background and describe what you're trying to accomplish?
To simplify this, pretend I have a single template. My template has a textbox that the user fills. When the user reaches the end, he must spawn a new page. This page should appear immediately after the current one so he can continue typing. However, if the user wants to go back and insert a page between two others, the document lets him do that. The problem is that now the newly spawned page has the same field names as the page right after it because both were spawned at the same page number in the document.
For your last question, you can have more than one (hidden) template in a document, so you could set up another for just the fields that you want to be the same, and spawn it.
I would like these fields to appear on the same page as all the other fields... can you do that with multiple spawns? For example, I have a text box on every spawned page with a title in it. I'd like that text box to be identical on all the pages and reflect any changes to the title made on any of the pages. If all the text boxes have different field names, I could write some script to change all the others, but I'd rather not have to add extra code if I can keep those few field names the same. -
Variables for Field Names.
This may be a silly one for ya but I am having a brain fart
now.
I am doing a dynamic form where the form questions are
created fro a database.
The different field names are dynamic variables generated via
itererations (++) from the database table.
The problem is that when I submit the form I need the field
names as the insert or update value to populate the values
statement in the query. I am having a problem locking down the
actual values to use for the insert or update statement.
I will need to use a loop to iterate through the variables.
Look at the code form the form.
Thanks in advance.
GeneToo much code for me to analyze.
But see if any of these development tricks lead the way for
you.
On your action page:
<cfdump var="#form#>
<cfoutput>
<cfloop collection="#form#" item="field">
#field# = #form[field]#<br>
</cfloop>
<cfoutput>
<cfoutput>
#form.fieldNames#<br>
<cfloop list="#form.fieldNames#" index="field">
#field# = #form[field]#<br>
</cfloop>
<cfoutput> -
Quick Viewer SQVI: how to switch to Technical Field Names on select screen?
Hi all,
I have created in SQ01 a Quick view and want to see the technical field names (and not the descriptions) on the selection screen.
In SE16 in the selection screen you go to
-> Settings
-> User parameters
unter 'keywords' you find FIELD NAME / LABEL and you can choose.
But in SQVI there is not that option.
Only in the creation of the query you can 'switch between techniucal name and long text'.
However if you execute and come to the selection screen then there is only the long text....
Who knows????
Thanks in advance,
ThomasI also tried with different options but it looks like SAP does not have option to display technical fields in output, however we can see technical names while creating query.
-
Alias a field name in a join query
I have a database with spaces in the field names (not my fault).
I am having a problem with the query because one of the fileds I am joining on has a space in its name. See bolded text.
SELECT *
FROM employee_passwords
INNER JOIN employee_general_info
ON employee_passwords.Employee_ID=employees.[Employee ID]
WHERE username = '#username#' AND password = '#password#'
So I get this error message
Error Executing Database Query.
[Macromedia][SQLServer JDBC Driver][SQLServer]Invalid object name 'employees.Employee ID'.
Is there a way to alias the employees.[Employee ID] field?Should be
ON employee_passwords.Employee_ID=employee_general_info.[Employee ID] -
JOIN TO FIELDS TO CREATE A NEW FIELD NAME
Dreamweaver MX / MySQL / PHP
I'm currently working on a DYNAMIC DROPDOWN SEARCH for a
recruitment company Where the visitor selects either "ANNUAL" or
"HOURLY" in the first menu and the second menu changes to either
£10,000 0r £4.50 for the wages section.
I can make the second menu change dynamically after the first
menu is defined, but the ID given to the second menu (by me) means
that it only ever searches the Hourly field or the Annual field but
not both. Let me explain...
I have a Jobs table and a salary table. Two fields in the
Jobs table are HOUR and ANNUAL and these are inserted using a menu
list drawn from a salary table. Its very easy to insert the data
into the Jobs table - click on the HOURLY menu, select the figure
and insert it into the HOUR field and then complete the process by
inserting the relevant figure into the ANNUAL field. The problem
lies in a customer search on the Public side,
I want the visitor to choose either HOUR or ANNUAL when
searching. I can do this using a dynamic dropdown menu (an MX
Extension) THE FIRST MENU is selected and then the second menu
changes to either the Annual or Hourly figures. BUT!!! I can only
give one ID to the second menu which is.....
S_jobHourly or S_jobAnnually
So it works to a degree - if I make the second menu's ID
value S_jobHourly it will return all the hourly figures chosen by
the user. But if the user clicks ANNUALLY then it returns nothing
because there are no hourly rates = £10,000.
Is there a way to perhaps join these two fields in a
recordset and then give that join a new name? So I could say name
the result S_jobSum and that means that the second dropdown menu
(given the value S_jobSum) would search both £10,000 and
£4.50 and then return the Job which matches?
Hope this is clear.
I'm really close on this and any help on this would be
absolutely fantastic.
Many thanks
HurstHi there
I'm wondering if it would be easier to dynamically change the
Label Value of the second drop down menu.... is that possible?
i.e "If first menu content = "Hourly Wage" then second label
id = S_JobHourly but if content is pulled from "Annual Wage" then
label iD = S_jobAnnually. A dynamic id label for the second
dropdown menu would solve this perfectly.
Any Ideas?
Thanks
Hurst Vanrooj -
Many to many join table with different column names
Hi have a joint table with different column names as foreign keys in the joining
tables...
e.g. i have a many to many reltnshp btwn Table A and Table B ..and join table
C
both have a column called pk.
and the join table C has columns call fk1 and fk2
does cmd require the same column name in the join table as in the joining table?
are there any workarounds?
thanksHI,
No, the foreign key column names in the join table do not have to match the primary
key names in the joined tables.
-thorick -
Easy ways to find/search different fields and tables relations?
Dear Friend ,
I am useing SE11 and SE16 to different table and field name relation . Is it any easy was to find table different table and field name relation .
Please reply urgently........
Max award for solHi,
I would wonder if you could use SE11 and SE16 for getting information on table relations.
You can use e.g. SQVI to create queries and you can set the link between tables (define the relation of them).
As for your question:
1 Please check this link:
http://www.erpgenie.com/abap/tables.htm
2.
You can use SE16 + DD30L to search for specific field / table.
BR
Csaba -
hi frds
Give me table name and field name of OPEN PO QUANTITY ..
thanks
Pari Vendhan.RSee the sample code for the open PO's based on Vendor
and do accordingly
*& Report ZMM_PO_REPORT
REPORT ZMM_PO_REPORT message-Id yb
NO STANDARD PAGE HEADING
LINE-COUNT 60(1)
LINE-SIZE 230.
D A T A B A S E T A B L E S D E C L A R A T I O N
TABLES: lfa1, " Vendor Master
t161, " PO Doc Types
t024, " Purchase Groups
ekko. " PO Header
T Y P E S D E C L A R A T I O N S
Purchase Orders Main Structure
TYPES: BEGIN OF s_po,
ebeln TYPE ebeln, " PO No.
ebelp TYPE ebelp, " PO Item
bstyp TYPE bstyp, " PO Category
bukrs TYPE bukrs, " Company Code
bsart TYPE bbsrt, " PO Type
lifnr TYPE lifnr, " Vendor No
ekgrp TYPE bkgrp, " Purchase Group
waers TYPE waers, " Currency
bedat TYPE etbdt, " PO Date
txz01 TYPE txz01, " Material Text
werks TYPE ewerk, " Plant
lgort TYPE lgort_d, " Storage Location
matkl TYPE matkl, " Material Group
menge TYPE bamng, " PR Quantity
meins TYPE bamei, " UOM
bprme TYPE bbprm, " Price Unit
netpr TYPE netpr, " Net price
peinh TYPE peinh, " Price Unit UOM
pstyp TYPE pstyp, " Item Category
knttp TYPE knttp, " Account Assignment Category
END OF s_po.
Purchase Orders History Structure
TYPES: BEGIN OF s_account,
ebeln TYPE ebeln, " PO No.
ebelp TYPE ebelp, " PO Item
gjahr TYPE mjahr, " Fiscal Year
belnr TYPE mblnr, " PO Invoice No
menge TYPE menge_d, " PR Quantity
wrbtr TYPE wrbtr, " Price in Local Currency
dmbtr TYPE dmbtr, " Price in Foreign Currency
waers TYPE waers, " Currency
shkzg TYPE shkzg, " Dr/Cr Indicator
END OF s_account.
Purchase Orders History Structure(Item Sum)
TYPES: BEGIN OF s_inv_sum,
ebeln TYPE ebeln, " PO No.
ebelp TYPE ebelp, " PO Item
menge TYPE menge_d, " PR Quantity
wrbtr TYPE wrbtr, " Price in Foreign Currency
waers TYPE waers, " Currency
END OF s_inv_sum.
Purchase Orders Main Structure
TYPES: BEGIN OF s_rep,
lifnr TYPE lifnr, " Vendor No
ebeln TYPE ebeln, " PO No.
ebelp TYPE ebelp, " PO Item
bstyp TYPE bstyp, " PO Category
bsart TYPE bbsrt, " PO Type
ekgrp TYPE bkgrp, " Purchase Group
waers TYPE waers, " Currency
bedat TYPE etbdt, " PO Date
txz01 TYPE txz01, " Material Text
werks TYPE ewerk, " Plant
lgort TYPE lgort_d, " Storage Location
matkl TYPE matkl, " Material Group
menge TYPE bamng, " PR Quantity
meins TYPE bamei, " UOM
bprme TYPE bbprm, " Price Unit
netpr TYPE netpr, " Net price
peinh TYPE peinh, " Price Unit UOM
pstyp TYPE pstyp, " Item Category
knttp TYPE knttp, " Account Assignment Category
name1 TYPE name1, " Plant
orewr TYPE netpr, " To be Invoiced Price
curr TYPE waers, " Inv Doc Currency
END OF s_rep.
D A T A D E C L A R A T I O N S
DATA: gv_title1 TYPE sylisel, " Report title
gv_dial. " Color flag
C O N S T A N T S D E C L A R A T I O N S
CONSTANTS: c_x VALUE 'X', " Flag X
c_h VALUE 'H', " Debit
c_vgabe TYPE vgabe VALUE '2'. " Transaction Type
I N T E R N A L T A B L E S D E C L A R A T I O N S
DATA: i_po TYPE STANDARD TABLE OF s_po WITH HEADER LINE,
" Purchase Order
i_inv TYPE STANDARD TABLE OF s_inv_sum WITH HEADER LINE,
" PO Invoice Values
i_rep TYPE STANDARD TABLE OF s_rep WITH HEADER LINE,
" PO Invoice Values
i_ekbe TYPE STANDARD TABLE OF s_account WITH HEADER LINE.
" PO Invoice Values
S E L E C T I O N S C R E E N *
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_lifnr FOR lfa1-lifnr MATCHCODE OBJECT kred,
s_ebeln FOR ekko-ebeln MATCHCODE OBJECT mekk,
s_bsart FOR t161-bsart,
s_ekgrp FOR t024-ekgrp,
s_bedat FOR ekko-bedat.
SELECTION-SCREEN END OF BLOCK b1.
I N I T I A L I Z A T I O N *
INITIALIZATION.
A T S E L E C T I O N - S C R E E N *
AT SELECTION-SCREEN.
Validate the screen fields
PERFORM validate_screen.
S T A R T - O F - S E L E C T I O N *
START-OF-SELECTION.
Fetch main data
PERFORM fetch_data.
T O P - O F - P A G E *
TOP-OF-PAGE.
Header of the List
PERFORM header.
E N D - O F - P A G E *
Footer
END-OF-PAGE.
ULINE.
E N D - O F - S E L E C T I O N *
END-OF-SELECTION.
Display the Report Output data
PERFORM display_data.
At Line-Selection
AT LINE-SELECTION.
When double clicked on EBELN display the details of Purchase Doc
PERFORM line_sel.
*& Form validate_screen
Validation of Selection Screen fields
FORM validate_screen .
Validation of Vendor Number
CLEAR lfa1-lifnr.
IF NOT s_lifnr[] IS INITIAL.
SELECT lifnr UP TO 1 ROWS
INTO lfa1-lifnr
FROM lfa1
WHERE lifnr IN s_lifnr.
ENDSELECT.
IF sy-subrc 0.
MESSAGE e000 WITH 'Invalid Vendor'(002).
ENDIF.
ENDIF.
Validation of PO Number
CLEAR ekko-ebeln.
IF NOT s_ebeln[] IS INITIAL.
SELECT ebeln UP TO 1 ROWS
INTO ekko-ebeln
FROM ekko
WHERE ebeln IN s_ebeln.
ENDSELECT.
IF sy-subrc 0.
MESSAGE e000 WITH 'Invalid Document Number'(003).
ENDIF.
ENDIF.
Validation of PO Document Type
CLEAR t161-bsart.
IF NOT s_bsart[] IS INITIAL.
SELECT bsart UP TO 1 ROWS
INTO t161-bsart
FROM t161
WHERE bsart IN s_bsart.
ENDSELECT.
IF sy-subrc 0.
MESSAGE e000 WITH 'Invalid Purchase Document Type'(004).
ENDIF.
ENDIF.
Validation of Purchasing Group
CLEAR t024-ekgrp.
IF NOT s_ekgrp[] IS INITIAL.
SELECT ekgrp UP TO 1 ROWS
INTO t024-ekgrp
FROM t024
WHERE ekgrp IN s_ekgrp.
ENDSELECT.
IF sy-subrc 0.
MESSAGE e000 WITH 'Invalid Purchasing Group'(005).
ENDIF.
ENDIF.
ENDFORM. " validate_screen
*& Form fetch_data
Fetching the PO related data from Database Tables
FORM fetch_data .
CLEAR i_po.
REFRESH i_po.
SELECT a~ebeln " PO No.
b~ebelp " PO Item
a~bstyp " PO Category
a~bukrs " Company Code
a~bsart " PO Type
a~lifnr " Vendor No
a~ekgrp " Purchase Group
a~waers " Currency
a~bedat " PO Date
b~txz01 " Material Text
b~werks " Plant
b~lgort " Storage Location
b~matkl " Material Group
b~menge " PR Quantity
b~meins " UOM
b~bprme " Price Unit
b~netpr " Net price
b~peinh " Price Unit UOM
b~pstyp " Item Category
b~knttp " Account Assignment Category
INTO TABLE i_po
FROM ekko AS a JOIN ekpo AS b
ON a~ebeln = b~ebeln
WHERE a~ebeln IN s_ebeln AND
a~lifnr IN s_lifnr AND
a~ekgrp IN s_ekgrp AND
a~bsart IN s_bsart AND
a~bedat IN s_bedat.
SORT i_po BY ebeln ebelp.
break-point.
IF NOT i_po[] IS INITIAL.
Fetch the PO History/Invoice Details from EKBE Table
CLEAR i_ekbe.
REFRESH i_ekbe.
SELECT ebeln " PO No.
ebelp " PO Item
gjahr " Fiscal Year
belnr " PO Invoice No
menge " PR Quantity
wrbtr " Price in Local Currency
dmbtr " Price in Foreign Currency
waers " Currency
shkzg " Dr/Cr Indicator
INTO TABLE i_ekbe
FROM ekbe
FOR ALL ENTRIES IN i_po
WHERE ebeln = i_po-ebeln AND
ebelp = i_po-ebelp AND
vgabe = c_vgabe.
IF sy-subrc = 0.
SORT i_ekbe BY ebeln ebelp.
LOOP AT i_ekbe.
IF i_ekbe-shkzg = c_h.
i_ekbe-wrbtr = i_ekbe-wrbtr * -1.
ENDIF.
MODIFY i_ekbe.
ENDLOOP.
break-point.
Sum up the Item wise Invoice totals
LOOP AT i_ekbe.
AT END OF ebelp.
READ TABLE i_ekbe INDEX sy-tabix.
SUM.
MOVE-CORRESPONDING i_ekbe TO i_inv.
APPEND i_inv.
ENDAT.
CLEAR i_inv.
ENDLOOP.
SORT i_inv BY ebeln ebelp.
break-point.
ENDIF.
ENDIF.
Move the Vendor Name and Invoice Values to I_rep Internal Table
LOOP AT i_po.
MOVE-CORRESPONDING i_po TO i_rep.
CLEAR i_inv.
READ TABLE i_inv WITH KEY ebeln = i_po-ebeln
ebelp = i_po-ebelp.
IF sy-subrc = 0.
i_rep-orewr = ( i_po-menge - i_inv-menge ) * i_po-netpr.
i_rep-curr = i_inv-waers.
ELSE.
i_rep-orewr = i_po-menge * i_po-netpr.
i_rep-curr = i_po-waers.
ENDIF.
break-point.
Get the Vendor Name
CLEAR lfa1-name1.
SELECT SINGLE name1 FROM lfa1 INTO lfa1-name1
WHERE lifnr = i_po-lifnr.
IF sy-subrc = 0.
i_rep-name1 = lfa1-name1.
ENDIF.
APPEND i_rep.
CLEAR i_rep.
break-point.
ENDLOOP.
SORT i_rep BY lifnr ebeln ebelp.
DELETE i_rep WHERE orewr LE 0.
break-point.
ENDFORM. " fetch_data
*& Form display_data
Display the Report Output data
FORM display_data .
DATA: lv_flag, " New Flag
lv_rec TYPE i. " No of Records
CLEAR lv_rec.
IF i_rep[] IS INITIAL.
MESSAGE e000 WITH 'No Data found'(022).
ELSE.
LOOP AT i_rep.
Toggle Color
PERFORM toggle_color.
IF lv_flag space.
NEW-LINE.
ENDIF.
At New Purchase Document
AT NEW ebeln.
WRITE:/1 sy-vline, 2(10) i_rep-ebeln INTENSIFIED OFF.
lv_flag = c_x.
lv_rec = lv_rec + 1.
ENDAT.
WRITE: 1 sy-vline,
12 sy-vline,13(4) i_rep-bsart,
17 sy-vline,18(10) i_rep-lifnr,
28 sy-vline,29(35) i_rep-name1,
64 sy-vline,65(4) i_rep-ekgrp,
69 sy-vline,70(10) i_rep-bedat,
80 sy-vline,81(5) i_rep-ebelp,
86 sy-vline,87(40) i_rep-txz01,
127 sy-vline,128(9) i_rep-matkl,
137 sy-vline,138(1) i_rep-pstyp,
139 sy-vline,140(1) i_rep-knttp,
141 sy-vline,142(4) i_rep-werks,
146 sy-vline,147(4) i_rep-lgort,
151 sy-vline,152(13) i_rep-menge UNIT i_rep-meins,
165 sy-vline,166(3) i_rep-meins,
169 sy-vline,170(15) i_rep-netpr CURRENCY i_rep-waers,
185 sy-vline,186(4) i_rep-waers,
190 sy-vline,191(5) i_rep-peinh,
196 sy-vline,197(4) i_rep-bprme,
201 sy-vline,202(15) i_rep-orewr CURRENCY i_rep-curr,
217 sy-vline,218(4) i_rep-curr,
222 sy-vline,223(7) i_rep-bstyp centered,
230 sy-vline.
NEW-LINE.
hide: i_rep-ebeln.
ENDLOOP.
ULINE.
FORMAT COLOR OFF.
WRITE : /2 'Total Number of Purchasing Documents:'(025) COLOR 3,
lv_rec COLOR 3.
ENDIF.
ENDFORM. " display_data
*& Form header
Write the Report Header
FORM header .
FORMAT RESET.
header
WRITE:/1(230) 'LIST OF PURCHASE DOCUMENTS PER VENDOR'(006) CENTERED.
SKIP.
FORMAT COLOR COL_HEADING.
ULINE.
WRITE:/1 sy-vline,2(10) 'Pur.Doc.No'(006) CENTERED,
12 sy-vline,13(4) 'Type'(007),
17 sy-vline,18(10) 'Vendor'(008) CENTERED,
28 sy-vline,29(35) 'Name'(009) CENTERED,
64 sy-vline,65(4) 'PGrp'(010) CENTERED,
69 sy-vline,70(10) 'Doc.Date'(012) CENTERED,
80 sy-vline,81(5) 'Item'(011),
86 sy-vline,87(40) 'Material Short Text'(024) CENTERED,
127 sy-vline,128(9) 'Mat.Group'(013),
137 sy-vline,138(1) 'I',
139 sy-vline,140(1) 'A',
141 sy-vline,142(4) 'Plnt'(014),
146 sy-vline,147(4) 'SLoc'(015),
151 sy-vline,152(13) 'Quantity'(016) CENTERED,
165 sy-vline,166(3) 'UoM'(017),
169 sy-vline,170(15) 'Net Value'(018) CENTERED,
185 sy-vline,186(4) 'Curr'(019),
190 sy-vline,191(5) 'Per'(020),
196 sy-vline,197(4) 'Unit'(021),
201 sy-vline,202(15) 'To be Invoiced'(023) CENTERED,
217 sy-vline,218(4) 'Curr'(019),
222 sy-vline,223(7) 'Doc.Cat'(026),
230 sy-vline.
ULINE.
ENDFORM. " header
*& Form toggle_color
This routine alters the color of the records in the list FORM toggle_color.
IF gv_dial = space.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
gv_dial = c_x.
ELSE.
FORMAT COLOR 1 INTENSIFIED OFF.
CLEAR gv_dial.
ENDIF.
ENDFORM. " toggle_color
*& Form LINE_SEL
*When double clicked on EBELN field display the details of Purchase Doc
FORM line_sel.
CASE sy-lsind.
WHEN '1'.
DATA: lv_field(20),
lv_value(10),
lv_bstyp like i_rep-bstyp.
clear: lv_bstyp,lv_value, lv_field.
GET CURSOR FIELD lv_field VALUE lv_value.
IF lv_field = 'I_REP-EBELN'.
IF NOT lv_value IS INITIAL.
READ LINE sy-index FIELD VALUE i_rep-bstyp
INTO lv_bstyp.
READ CURRENT LINE FIELD VALUE i_rep-bstyp INTO lv_bstyp.
if lv_bstyp = 'F'.
SET PARAMETER ID 'BES' FIELD lv_value.
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
elseif ( lv_bstyp = 'K' or lv_bstyp = 'L' ).
SET PARAMETER ID 'VRT' FIELD lv_value.
CALL TRANSACTION 'ME33' AND SKIP FIRST SCREEN.
elseif lv_bstyp = 'A'.
SET PARAMETER ID 'ANF' FIELD lv_value.
CALL TRANSACTION 'ME43' AND SKIP FIRST SCREEN.
endif.
ENDIF.
ENDIF.
ENDCASE.
ENDFORM. " line_sel{code]
<REMOVED BY MODERATOR>
kushagra
Edited by: Alvaro Tejada Galindo on Feb 18, 2008 2:03 PM -
Using variable with the same name as field name?
I have a complex proc where I have variables with the same name as field name used on a query. something like this:
SELECT a.id_table WHERE a.id_table = id_table
where the last id_table is a parameter sent to the proc:
declare procedure myproc(id_table int)
Is there any way or notation to declare the variable inside the query as a variable or I have to use a different name?Well, variables are not the only thing you have to change if you want to switch to Oracle.
Although I don't think it is good practice (to use variable name same as column name), here is one example how you can achieve it using EXECUTE IMMEDIATE and bind variable
SQL> select deptno, count(1)
2 from scott.emp
3 group by deptno;
DEPTNO COUNT(1)
30 6
20 5
10 3
SQL> set serveroutput on
SQL> declare
2 deptno varchar2(10);
3 i number;
4 begin
5 deptno:=10;
6 execute immediate
7 'select count(1) from scott.emp where deptno=:deptno' into i using deptno;
8 dbms_output.put_line('OUT ---> '||i);
9 end;
10 /
OUT ---> 3
PL/SQL procedure successfully completed.
SQL> Message was edited by:
tekicora
Message was edited by:
tekicora -
Hi all,
I used the following code to create a new Database (ScottChangDB) and a new Table (marvel) in my SQL Server 2012 Management Studio (SSMS2012) successfully:
-- ScottChangDB.sql saved in C://Documents/SQL Server XQuery_MacLochlainns Weblog_code
-- 14 April 2015 09:15 AM
USE master
IF EXISTS
(SELECT 1
FROM sys.databases
WHERE name = 'ScottChangDB')
DROP DATABASE ScottChangDB
GO
CREATE DATABASE ScottChangDB
GO
USE ScottChangDB
CREATE TABLE [dbo].[marvel] (
[avenger_name] [char] (30) NULL, [ID] INT NULL)
INSERT INTO marvel
(avenger_name,ID)
VALUES
('Hulk', 1),
('Iron Man', 2),
('Black Widow', 3),
('Thor', 4),
('Captain America', 5),
('Hawkeye', 6),
('Winter Soldier', 7),
('Iron Patriot', 8);
SELECT avenger_name FROM marvel ORDER BY ID For XML PATH('')
DECLARE @x XML
SELECT @x=(SELECT avenger_name FROM marvel ORDER BY ID FOR XML PATH('Marvel'))--,ROOT('root'))
SELECT
person.value('Marvel[4]', 'varchar(100)') AS NAME
FROM @x.nodes('.') AS Tbl(person)
ORDER BY NAME DESC
--Or if you want the completed element
SELECT @x.query('/Marvel[4]/avenger_name')
DROP TABLE [marvel]
Now I am trying to create my first XML Schema Collection to do the Validation on the Field Name (Column Title) of the "marvel" Table. I have studied Chapter 4 XML SCHEMA COLLECTIONS of the book "Pro SQL Server 2008 XML" written by
Michael Coles (published by Apress) and some beginning pages of XQuery Language Reference, SQL Server 2012 Books ONline (published by Microsoft). I mimicked Coles' Listing 04-05 and I wanted to execute the following first-drafted sql in
my SSMS2012:
-- Reference [Scott Chang modified Listing04-05.sql of Pro SQL Server 2008 XML by Michael Coles (Apress)]
-- [shcColes04-05.sql saved in C:\\Documents\XML_SQL_Server2008_code_Coles_Apress]
-- [executed: 2 April 2015 15:04 PM]
-- shcXMLschemaTableValidate1.sql in ScottChangDB of SQL Server 2012 Management Studio (SSMS2012)
-- saved in C:\Documents\XQuery-SQLServer2012
tried to run: 15 April 2015 ??? AM
USE ScottChangDB;
GO
CREATE XML SCHEMA COLLECTION dbo. ComplexTestSchemaCollection_all
AS
N'<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="marvel">
<xsd:complexType>
<xsd:all>
<xsd:element name="avenger_name" />
<xsd:element name="ID" />
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:schema>';
GO
DECLARE @x XML (dbo. ComplexTestSchemaCollection_all);
SET @x = N'<?xml version="1.0"?>
<marvel>
<avenger_name>Thor</name>
<ID>4</ID>
</marvel>';
SELECT @x;
GO
DROP XML SCHEMA COLLECTION dbo.ComplexTestSchemaCollection_all;
GO
I feel that drafted sql is very shaky and it needs the SQL Server XML experts to modify to make it work for me. Please kindly help, exam the coding of my shcXMLTableValidate1.sql and modify it to work.
Thanks in advance,
Scott ChangHi Scott,
2) Yes, FOR XML PATH clause converts relational data to XML format with a specific structure for the "marvel" Table. Regarding validate all the avenger_names, please see below
sample.
DECLARE @x XML
SELECT @x=(SELECT ID ,avenger_name FROM marvel FOR XML PATH('Marvel'))
SELECT @x
SELECT
n.value('avenger_name[1]','VARCHAR(99)') avenger_name,
n.value('ID[1]','INT') ID
FROM @x.nodes('//Marvel') Tab(n)
WHERE n.value('ID[1]','INT') = 1 -- specify the ID here
--FOR XML PATH('Marvel') --uncommented this line if you want the result as element type
3)i.check the xml schema content
--find xml schema collection
SELECT ss.name,xsc.name collection_name FROM sys.xml_schema_collections xsc JOIN sys.schemas ss ON xsc.schema_id= ss.schema_id
select * from sys.schemas
--check the schema content,use the name,collection_name from the above query
SELECT xml_schema_namespace(N'name',N'collection_name')
3)ii. View can be viewed as virtual table. Use a view to list the XML schema content.
CREATE VIEW XSDContentView
AS
SELECT ss.name,xsc.name collection_name,cat.content
FROM sys.xml_schema_collections xsc JOIN sys.schemas ss ON xsc.schema_id= ss.schema_id
CROSS APPLY(
SELECT xml_schema_namespace(ss.name,xsc.name) AS content
) AS cat
WHERE xsc.name<>'sys'
GO
SELECT * FROM XSDContentView
By the way, it would be appreciated if you can spread your questions into posts. For any question, feel free to let me know.
Eric Zhang
TechNet Community Support
Maybe you are looking for
-
How can I transfer my itunes library edits to my computer music
I got my PC music that I transfer to my itunes library, and I do a lot of editing of my itunes music and I would like it to automaticly edit my PC music so that when I lose my itunes music I could go back to my PC and download it again without having
-
Why are my placed images in Illustrator dimmed?
I just got a fresh install of Illustrator CC and every time I place a raster image into my document, it appears dim or very light. When I go to export the image, the PNG file displays the image correctly.
-
Hi We just upgraded to BW 3.5 (Level 11) with Content 3.5.3 (Level 2) and i now wanted to use the new Master Web Item "Web Template". The problem i now have is, that this item is not on the list when starting WAD. I checked R3-system. Class CL_RSR_WW
-
ISE integration with SMS gateway required license
Hello All, We have cisco WLC with guest wireless access configured to use local database. the managment requires new solution to send cridintials to user throug SMS after the user signup through portal. we decided to use the cisco ISE. my question is
-
Hyperion Financial Reporting - Studio V11.1.2
I have a report with a row and column template in it I am wanting the format for the row template for five lines to have one decimal point but I do not need the other data in the other row accounts to include decimals for the row or columns. I tried