Joining tables fields
hi all,
how to join 7 different table fields to final data? i need to pass all 7 table fields to final .
can u guys help me out thru code.
TYPES : BEGIN OF TY_FINAL,
LDDAT TYPE VBEP-LDDAT,
WERKS TYPE VBAP-WERKS,
LIFSK TYPE VBAK-LIFSK,
BSTKD TYPE VBKD-BSTKD,
AUART TYPE VBAK-AUART,
AUDAT TYPE VBAK-AUDAT,
VBELN TYPE VBAK-VBELN,
POSNR TYPE VBAP-POSNR,
KUNNR TYPE VBPA-KUNNR,
MATNR TYPE VBAP-MATNR,
WMENG TYPE VBEP-WMENG,
NETWR TYPE VBAK-NETWR,
AUGRU TYPE VBAK-AUGRU,
FAKSK TYPE VBAK-FAKSK,
ARKTX TYPE VBAP-ARKTX,
VKGRP TYPE VBAK-VKGRP,
VKBUR TYPE VBAK-VKBUR,
LIFNR TYPE VBPA-LIFNR,
LIFNR TYPE VBPA-LIFNR-LP,
PERNR TYPE VBPA-PERNR,
LPRIO TYPE VBAP-LPRIO,
INCO1 TYPE VBKD-INCO1,
ABLAD TYPE KUWEV-ABLAD,
BSTDK TYPE VBKD-BSTDK,
ZTERM TYPE VBKD-ZTERM,
WAERK TYPE VBAK-WAERK,
ERNAM TYPE VBAK-ERNAM,
ABGRU TYPE VBAP-ABGRU,
LFGSK TYPE VBUK-LFGSK,
PRSDT TYPE VBKD-PRSDT,
VDATU TYPE VBAK-VDATU,
CHARG TYPE VBAP-CHARG,
VSTEL TYPE VBAP-VSTEL,
LGORT TYPE VBAP-LGORT,
END OF TY_FINAL.
these r da fields of different table
thanks®ards,
sumanth reddy
Edited by: sumanth reddy on Feb 26, 2009 4:37 PM
hi
declare 7 internal tables for ur 7 tables and one final internal table to hold all the data.
like
select vbeln vbtyp erdat kunnr vkorg vtweg spart from vbak
into table i_vbak.........
select vbeln posnr matnr arktx werks kwmeng from vbap
into table i_vbap for all entries in i_vbak where vbeln = i_vbak-vbeln.....
select vbelv posnv erdat vbeln posnn matnr vbtyp_n from vbfa
into table i_vbfa for all entries in i_vbap where vbelv = i_vbap-vbeln....
select vbeln posnr rfsta from vbup into table i_vbup for all entries in i_vbfa
where vbeln = i_vbfa-vbelv......
select vbeln posnr kwmeng from vbap into table i_vbap1 for all entries in i_vbfa
where vbeln = i_vbfa-vbeln.....
select vbeln posnr gbsta from vbup into table i_vbup1 for all entries in i_vbap1
where vbeln = i_vbap1-vbeln.....etc
and while looping into the final internal table
loop at i_vbap.
move i_vbap-vbeln to i_final-vbeln.
move i_vbap-posnr to i_final-posnr.
read table i_vbfa with key vbelv = i_vbap-vbeln
posnv = i_vbap-posnr.
if sy-subrc = 0.
move i_vbfa-vbeln to i_final-vbeln1.
move i_vbfa-posnn to i_final-posnn.
endif.
read table i_vbap1 with key vbeln = i_final-vbeln1
posnr = i_final-posnn.
if sy-subrc = 0.
endif.
read table i_vbap1 with key vbeln = i_final-vbeln1
posnr = i_final-posnn.
if sy-subrc = 0.
endif.
read table i_vbup with key vbeln = i_vbap-vbeln
posnr = i_vbap-posnr.
if sy-subrc = 0.
endif.
read table i_vbak with key vbeln = i_vbap-vbeln
binary search.
if sy-subrc = 0.
endif.
append i_final.
endloop.
u have to read all the internal tables based on the key common fields and put into final itab.
Regards
Regards
Similar Messages
-
Additional field in join table for CMP EJB
Hello,
I'm trying to perform this task using CMP entity beans:
The entity A has a CMR relation of cardinality m-n with entity B (bidirectional) (This is working fine).
I want to add a parameter to the relation.
Ex : When I find that A1 is linked to B1, I need to perform "x" times an action. x would be my parameter, and I would have kept this parameter as an additional column in the join table A_TO_B.
Could anyone provide an example of how to perform this with CMP EJB?
NOTE: I'm using OC4J 10g 9.0.4 standalone (and cannot change my version).
Thanks
TanguyManohar,
You need to create an append structure for table VBAP (for example ZAVBAP) using SE11. In this structure you create your ZZ fields. If you need a non-SAP domain/data element for your field then you need to create it first using the same transaction and activate it. Attach ZAVBAP to VBAP so the SE11 shows:
.APPEND in the Fields column and
ZAVBAP in the Field type column.
Your ZZ fields will be shown automatically.
When you have finished then activate your ZAVBAP structure. You will notice when you go VA01 (for example) that a lot of programs are being recompiled. Don't worry. It will be ok.
The user-exit screen number for items is 8459 (in program SAPMV45A).
Thanks,
Wojtek -
In SQ02 after joining table if we want write condition on other field how ?
In SQ03 after joining table if we want write condition on some fields
for filtering records then what is the procedure.Please check forum subject. This is not a right forum for your question. Close your thread and post it on a proper forum.
Thanks,
Gordon -
CMP additional field in join table
I'm sorry if this question was already post on the forum, but I could not find any answer....
I have an existing application which is using CMP entity beans.
A and B have a many to many relation, then the relation is mapped to a join table with 2 columns (key of A, key of B)
I need to modify this relation in order to specify the number of B linked to A for a given relation, then adding a column to the join table :
(key of A, key of B, MyParameter)
Is there a way to specify the parameter in the beans ?
Do I have to change my CMP entity bean to BMP beans?
If I do have to use BMP, many other CMP entity beans have relations with one of the beans that I will have to modify to BMP. Will I have to transform all the CMP beans with relation to BMP beans (then almost all the application) to BMP?
Thanks a lot for your answers.Manohar,
You need to create an append structure for table VBAP (for example ZAVBAP) using SE11. In this structure you create your ZZ fields. If you need a non-SAP domain/data element for your field then you need to create it first using the same transaction and activate it. Attach ZAVBAP to VBAP so the SE11 shows:
.APPEND in the Fields column and
ZAVBAP in the Field type column.
Your ZZ fields will be shown automatically.
When you have finished then activate your ZAVBAP structure. You will notice when you go VA01 (for example) that a lot of programs are being recompiled. Don't worry. It will be ok.
The user-exit screen number for items is 8459 (in program SAPMV45A).
Thanks,
Wojtek -
Joining tables with "similar" field values
I have run into a situation where I want to join two tables on a field called U_LotusBox. In my main table the the feild can contain values like 1 or 2 or 3 or 1,2,3,4. That's 1 comma 2 comma 3 comma 4. My field in the second tables contains only single digit values, like 1 ,2, 3 up to 5.
When the two fields are identical I am able to retrieve data. But if my field in the main contains a value of 1,2,3 and my secondary table field value is 2 I get no data returned because the two fields are not identical.
Is it possible to have a join that is "fuzzy" meaning that if the main table field values contains the value of the secondary field value, 2 in my example would it be possible to return data?
Any thoughts would be appreciated.Ralph,
Here in high-level details is an SQL example of creating two tables (test1 and test2) with one column in each table (col_a and col_b, respectively) to show how a join on a substring of one column can be tied to a column of another table:
create table test1 (col_a char(5))
create table test2 (col_b char(1))
insert into test1 values ('1')
insert into test1 values ('1,2,3')
insert into test2 values ('1')
insert into test2 values ('2')
select col_a,test2_tbl1.col_b
from test1 inner join test2 as test2_tbl1 on col_a=test2_tbl1.col_b or
substring(col_a,1,1)=test2_tbl1.col_b or
substring(col_a,3,1)=test2_tbl1.col_b or
substring(col_a,5,1)=test2_tbl1.col_b
col_a col_b
~~~~~~~|~~~~~
1 1
1,2,3 1
1,2,3 2
thanks,
John -
SQVI - Join tables using similar fields (but not same)
Hi folks!
I would like to know if there is a way to do a join between two tables thru fields that are similar but not exactly the same. For example, I need to join tables EKKO and CDHDR, where the PO numbers do exist in both the tables (EKKO-EBELN and CDHDR-OBJECTID), but the fields are different. Is it possible to achieve such kind of a join?
Appreciate your help.
Regards,
Anwar.>
Mohammad Anwar wrote:
though their data type is the same (CHAR).
unfortunately it is not enough... You have to select separately from the two tables and merge the data somehow in the program. -
Choose field from joined table based on another field?
Good morning!
Is it possible to select a field from a joined table row based on another field? Consider the following data in the CVALUES table:
ID C1 C2 C3 C4 C5 C6
T1 9.6 10.3 12.4 19.6 19.6 0
T7 9.6 10.4 0 0 0 0
T3 8.2 9.9 11.4 19.6 19.6 0
T8 8.3 10.7 13.5 20.7 0 0
T5 9.4 10.3 12.7 22.9 19.6 0
...And the following data in the MDETAIL table:
ID MDATE CNUM ...
T1 03/28/2012 18:00:00 4
T1 03/28/2012 18:00:00 1
T8 03/29/2012 06:00:00 6
T8 03/29/2012 06:00:00 5
...I want to get the column from CVALUES corresponding to the CNUM field in the MDETAIL table. I'm currently doing this:
SELECT m.t1, m.mdate,
CASE WHEN m.cnum = 1 THEN c.c1
WHEN m.cnum = 2 THEN c.c2
WHEN m.cnum = 3 THEN c.c3
WHEN m.cnum = 4 THEN c.c4
WHEN m.cnum = 5 THEN c.c5
WHEN m.cnum = 6 THEN c.c6 END AS cvalue
FROM mdetail m
JOIN cvalues c ON m.id = c.idThe records in the CVALUES table are unique; only one row per ID.
This method works, and it's fast but it's messy code and I think there has to be a better way to do it. I use the cvalue value in several calculations so every calculation I use it in has this giant glob of CASE in it!Since you're comparing the same column against scalar values, the CASE statement could be simplified in a similar way :
CASE m.cnum
WHEN 1 THEN c.c1
WHEN 2 THEN c.c2
WHEN 3 THEN c.c3
WHEN 4 THEN c.c4
WHEN 5 THEN c.c5
WHEN 6 THEN c.c6
END AS cvalueSince performance is not the issue here, now it depends on what you consider "more readable".
Using a one-liner piece of code certainly makes the query looks less bulky, but I won't be so sure about readability and immediate understanding. -
How to show all table fields in correct alv disply
Hi all,
This is my report that disply in ALV . but this is only displying the join table (t_p0001_p0002) fields.i want to disply the other two table fields i.e t_pa0315 and t_pa0007.what is the logic to ALV disply the other two table fields like the table t_pa0001_pa0002.pls help me regarding this.
send me the code its urgent.
thanks!
Vipin
pls find the code below:->
REPORT Y_WP03 .
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = &2.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
TYPE-POOLS: slis. " ALV Global types
tables:pa0001,
pa0315,
pa0007,
disvariant.
Selection-Screen
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
*SELECTION-SCREEN SKIP 1.
SELECT-OPTIONS: s_pernr FOR pa0001-pernr. " Personnel No
SELECT-OPTIONS: s_orgeh FOR pa0001-orgeh . " Organization unit
SELECT-OPTIONS: s_werks FOR pa0001-werks. " Personnel Area
SELECT-OPTIONS: s_plans FOR pa0001-plans. " Position
SELECT-OPTIONS: s_ebeln FOR pa0315-ebeln. " Purchase order
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION-SCREEN BEGIN OF BLOCK b2k2 WITH FRAME TITLE text-002.
*SELECT-OPTIONS: s_var FOR disvariant-variant.
PARAMETERS: p_disva1 LIKE disvariant-variant.
SELECTION-SCREEN END OF BLOCK b2k2.
Type Definition *
TYPES :
BEGIN OF ty_pa0001_pa0002,
pernr TYPE pa0001-pernr , " Personnel no.
endda TYPE pa0001-endda , " end date
begda TYPE pa0001-begda , " start date
bukrs TYPE pa0001-bukrs , " company code
werks TYPE pa0001-werks , " Personnnel area
persg TYPE pa0001-persg , " Employee group
persk TYPE pa0001-persk , " Employee subgroup
btrtl TYPE pa0001-btrtl , " Personnnel subarea
abkrs TYPE pa0001-abkrs , " Payroll area
kostl TYPE pa0001-kostl , " cost center
orgeh TYPE pa0001-orgeh , " Organizational Unit
plans TYPE pa0001-plans , " Position
nachn TYPE pa0002-nachn , " Last name
vorna TYPE pa0002-vorna , " First name
midnm TYPE pa0002-midnm , " Middle name
END OF ty_pa0001_pa0002 ,
BEGIN OF ty_pa0315,
pernr TYPE pa0315-pernr , " Personnel no.
kostl TYPE pa0315-kostl , " Sending cost center
lstar TYPE pa0315-lstar , " Activity type
werks TYPE pa0315-werks , " Plant
lifnr TYPE pa0315-lifnr , " Vendor number
ebeln TYPE pa0315-ebeln , " Sending pruchase ord
ebelp TYPE pa0315-ebelp , " Sending PO item
lstnr TYPE pa0315-lstnr , " Activity number
END OF ty_pa0315,
BEGIN OF ty_pa0007,
pernr TYPE pa0007-pernr,
schkz TYPE pa0007-schkz,
END OF ty_pa0007.
*BEGIN OF ty_pa0002,
pernr TYPE pa0002-pernr,
nachn TYPE pa0002-nachn,
vorna TYPE pa0002-vorna,
midnm TYPE pa0002-midnm,
*END OF ty_pa0002.
Data Declaration *
DATA :
t_pa0001_pa0002 TYPE STANDARD TABLE OF ty_pa0001_pa0002 ,
w_pa0001_pa0002 TYPE ty_pa0001_pa0002 ,
t_pa0315 TYPE STANDARD TABLE OF ty_pa0315 ,
w_pa0315 TYPE ty_pa0315 ,
t_pa0007 TYPE STANDARD TABLE OF ty_pa0007 ,
w_pa0007 TYPE ty_pa0007 .
t_pa0002 TYPE STANDARD TABLE OF ty_pa0002 ,
w_pa0002 TYPE ty_pa0002 .
START-OF-SELECTION .
SELECT a~pernr
a~endda
a~begda
a~bukrs
a~werks
a~persg
a~persk
a~btrtl
a~abkrs
a~kostl
a~orgeh
a~plans
b~nachn
b~vorna
b~midnm
INTO TABLE t_pa0001_pa0002
FROM pa0001 AS a INNER JOIN pa0002 AS b
ON apernr = bpernr
WHERE a~pernr IN s_pernr
AND a~werks IN s_werks
AND a~orgeh IN s_orgeh
AND a~plans IN s_plans.
SORT t_pa0001_pa0002 BY pernr .
IF NOT t_pa0001_pa0002[] IS INITIAL .
SELECT pernr
kostl
lstar
werks
lifnr
ebeln
ebelp
lstnr
FROM pa0315
INTO TABLE t_pa0315
FOR ALL ENTRIES IN t_pa0001_pa0002
WHERE pernr = t_pa0001_pa0002-pernr
AND kostl = t_pa0001_pa0002-kostl
AND ebeln IN s_ebeln.
SELECT pernr
schkz
FROM pa0007
INTO TABLE t_pa0007
FOR ALL ENTRIES IN t_pa0001_pa0002
WHERE pernr = t_pa0001_pa0002-pernr.
SELECT pernr
nachn
vorna
midnm
FROM pa0002
INTO TABLE t_pa0002
FOR ALL ENTRIES IN t_pa0001
WHERE pernr = t_pa0001-pernr .
ENDIF.
PERFORM f_display_data.
FORM f_display_data.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
Build the field catalog
m_fieldcat 'PERNR' 'PA0001'.
m_fieldcat 'NACHN' 'PA0002'.
m_fieldcat 'VORNA' 'PA0002'.
m_fieldcat 'MIDNM' 'PA0002'.
m_fieldcat 'BUKRS' 'PA0001'.
m_fieldcat 'WERKS' 'PA0001'.
m_fieldcat 'PERSG' 'PA0001'.
m_fieldcat 'PERSK' 'PA0001'.
m_fieldcat 'BTRTL' 'PA0001'.
m_fieldcat 'ABKRS' 'PA0001'.
m_fieldcat 'ORGEH' 'PA0001'.
m_fieldcat 'PLANS' 'PA0001'.
m_fieldcat 'SCHKZ' 'PA0007'.
m_fieldcat 'KOSTL' 'PA0315'.
m_fieldcat 'LSTAR' 'PA0315'.
m_fieldcat 'WERKS' 'PA0315'.
m_fieldcat 'LIFNR' 'PA0315'.
m_fieldcat 'EBELN' 'PA0315'.
m_fieldcat 'EBELP' 'PA0315'.
m_fieldcat 'LSTNR' 'PA0315'.
m_fieldcat 'BEGDA' 'PA0001'.
m_fieldcat 'ENDDA' 'PA0001'.
Display the list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = lt_fieldcat
TABLES
t_outtab = t_pa0001_pa0002.
ENDFORM. " F_DISPLAY_DATA_VBAK
FORM USER_COMMAND *
FORM user_command USING u_ucomm TYPE syucomm
us_selfield TYPE slis_selfield. "#EC CALLED
CASE u_ucomm.
WHEN '&IC1'.
READ TABLE t_pa0001_pa0002 INDEX us_selfield-tabindex INTO
w_pa0001_pa0002.
CHECK sy-subrc EQ 0.
ENDCASE.
ENDFORM. " USER_COMMANDHey,
Look at ur code.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = lt_fieldcat
TABLES
t_outtab = <b>t_pa0001_pa0002</b>.
Here you're passing only the join table t_pa0001_pa0002. If you want to display the other tables as well, then u must have an internal table that has the columns of all the 3 tables. Then u need to buil;d the fieldcatalog accordingly and then display that table,
Cheers,
Sam -
How to use a MAP whithout join table
Hello
I am still evaluating KODO ;-)
I am using kodo 3.1.2 with an evaluation version
linux (kernel 2.6)
SUN JDK 1.4.2_04
MYSQL MAX 4.0.18 -Max
IDEA 4.0.3 and ANT 1.5.4 (to be exhaustive)
I am wondering how to configure the following mapping involving a Map. :
public class Translation {
private String locale;
private String txt;
public class TranslatableDescription {
/**Map of Key=locale as String; Value = {@link Translation}*/
==> private Map translations = new HashMap(); <==
public void addATranslation(Translation t){
translations.put(t.getLocale(), t);
file package.jdo :
<?xml version="1.0"?>
<jdo>
<package name="data">
<class name="Translation"/>
<class name="TranslatableDescription">
<field name="translations">
<map key-type="java.lang.String"
value-type="tutorial.data.Translation"/>
<extension vendor-name="kodo" key="jdbc-key-size" value="10"/>
</field>
</class>
</package>
</jdo>
The default Mapping generate a join table : TRANS_TRANSLATION which works
fine, but I would like to remove this table by adding a
colonne in the "TRANSLATION" table containing the JDOID of the
TRANSLATIONDESCRIPTION owner of this TRANSLATION.
I have made some try like this one in the mapping file
<class name="TranslatableDescription">
<field name="translations">
<jdbc-field-map type="n-many-map" key-column="LOCALE"
ref-column.JDOID="OWNERJDOID" table="TRANSLATION0"
value-column.JDOID="JDOID"/>
</field>
The schema generated in my DB is correct but when I try to persist some
objects I have the following Exception :
727 INFO [main] kodo.jdbc.JDBC - Using dictionary class
"kodo.jdbc.sql.MySQLDictionary" (MySQL 4.0.18'-Max' ,MySQL-AB JDBC Driver
mysql-connector-java-3.0.10-stable ( $Date: 2004/01/13 21:56:18 $,
$Revision: 1.27.2.33 $ )).
Exception in thread "main" kodo.util.FatalDataStoreException: Invalid
argument value, message from server: "Duplicate entry '2' for key 1"
{prepstmnt 8549963 INSERT INTO TRANSLATION0 (JDOID, LOCALESTR, OWNERJDOID)
VALUES (?, ?, ?) [reused=0]} [code=1062, state=S1009]
NestedThrowables:
com.solarmetric.jdbc.ReportingSQLException: Invalid argument value,
message from server: "Duplicate entry '2' for key 1" {prepstmnt 8549963
INSERT INTO TRANSLATION0 (JDOID, LOCALESTR, OWNERJDOID) VALUES (?, ?, ?)
[reused=0]} [code=1062, state=S1009]
java.sql.BatchUpdateException: Invalid argument value, message from
server: "Duplicate entry '2' for key 1"
at kodo.jdbc.sql.SQLExceptions.getFatalDataStore(SQLExceptions.java:42)
at kodo.jdbc.sql.SQLExceptions.getFatalDataStore(SQLExceptions.java:24)
at kodo.jdbc.runtime.JDBCStoreManager.flush(JDBCStoreManager.java:594)
at
kodo.runtime.DelegatingStoreManager.flush(DelegatingStoreManager.java:152)
at
kodo.runtime.PersistenceManagerImpl.flushInternal(PersistenceManagerImpl.java:964)
at
kodo.runtime.PersistenceManagerImpl.beforeCompletion(PersistenceManagerImpl.java:813)
at kodo.runtime.LocalManagedRuntime.commit(LocalManagedRuntime.java:69)
at
kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:542)
at
tutorial.CreateTranslatableDescription.main(CreateTranslatableDescription.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(Unknown Source)
I have the feeling that KODO does try to make diffent row in the table
"TRANSLATION0" for the TRANSLATION and the MAP.
So, is this kind of mapping supported by KODO and if yes, how can I
configure it.
Thank you for your help
NicolasSo, is this kind of mapping supported by KODO and if yes, how can I
configure it.It is not directly supported. You can fake it using a one-many mapping
(see thread: Externalizing Map to Collection of PC), but unless you must
map to an existing schema, it's probably not worth the effort. (Note:
also there is a bug that actually prevents this from working with 3.1.2;
the bug is fixed for 3.1.3, but it hasn't been released yet). -
How to get data from COSP table, field HRKFT as the key to data from PM?
Dear ladies and gentlemen!
I need to get data from COSP table, field HRKFT as the key to data from PM tables (AFKO and AUFK).
The problem is that it is a key field to the COSP, and all non-key fields as an alternative to HRKFT are not suitable for this task.
All this is necessary for the extractor, which loads the data from the R \ 3 systems in the BW-system. I need to perform SELECT from a table COSP and maybe also JOIN, most likely between tables COSP and AUFK.
What should I do in this case?
Thank you very much in advance!From information on help.sap.com I've made a conclusion that one of possible solutions in theory is to modify standard extractor PM_OM_OPA_1 in order to make HRKFT field available for work, because by default it is hidden by SAP and not available for use as a key field.
Of course, it's not a very good solution, but for now I know no other way to solve this problem.
Maybe someone knows better ways? In this case I will be very grateful for any help!
Moderator: You'd better post it on BI forums -
Modify the Field Type of standard Table fields in a Query
Hello. I have a question.
Is there a way to "modify" the field type for standard table fields that are included in a Query?
I made a simple query out of a join of tables, but several fields have a lot of decimals, and I would like to present them in the query without any decimals, just as a regular "N" field.
I tried the possibility of creating extra local fields where all I do is transfer the value to the new "N" field, but I have many fields like this, so if there's a better way; I'd prefer that.
Maybe somewhere in the InfoSet there's a way to modify the type of the standard table fields?
Thank you.Hi,
This document may help you out.
[http://help.sap.com/saphelp_erp60_sp/helpdata/en/d2/cb4468455611d189710000e8322d00/frameset.htm|http://help.sap.com/saphelp_erp60_sp/helpdata/en/d2/cb4468455611d189710000e8322d00/frameset.htm]
Cheers, -
Hi All,
Here I am facing the problem in Joining table I have S031,s032,makt,marc,I need a field ATWRT field from CAWN table,I did't find any link for this above from tables, any one please help me how to find out.
REPORT ZMMTEST.
tables:s031,s032,makt,marc.
DATA : BEGIN OF itab1 OCCURS 0,
matnr TYPE s031-matnr,
lgort TYPE s031-lgort,
werks TYPE s031-werks,
spmon TYPE s031-spmon,
magbb type S031-magbb,
wagbb type S031-wagbb,
azubb type S031-azubb,
aagbb type S031-aagbb,
END OF itab1.
DATA : BEGIN OF itab2 OCCURS 0,
matnr like makt-matnr,
maktx like makt-maktx,
END OF itab2.
DATA : BEGIN OF itab3 OCCURS 0,
matnr TYPE marc-matnr,
werks type marc-werks,
ekgrp type marc-ekgrp,
END OF itab3.
DATA : BEGIN OF itab4 OCCURS 0 ,
matnr TYPE s032-matnr,
lgort TYPE s032-lgort,
werks TYPE s032-werks,
mbwbest type s032-mbwbest,
wbwbest type s032-wbwbest,
END OF itab4.
data : begin of itab5 occurs 0,
objek type ausp-objek,
atwrt type cawn-atwrt,
end of itab5.
DATA : BEGIN OF itab_final1 OCCURS 0,
matnr TYPE s031-matnr,
lgort TYPE s031-lgort,
werks TYPE s031-werks,
spmon TYPE s031-spmon,
magbb type S031-magbb,
wagbb type S031-wagbb,
azubb type S031-azubb,
aagbb type S031-aagbb,
maktx TYPE makt-maktx,
ekgrp type marc-ekgrp,
mbwbest type s032-mbwbest,
wbwbest type s032-wbwbest,
END OF itab_final1.
DATA : BEGIN OF itab_final OCCURS 0,
matnr TYPE s031-matnr,
lgort TYPE s031-lgort,
werks TYPE s031-werks,
spmon TYPE s031-spmon,
magbb type S031-magbb,
wagbb type S031-wagbb,
azubb type S031-azubb,
aagbb type S031-aagbb,
maktx TYPE makt-maktx,
ekgrp type marc-ekgrp,
mbwbest type s032-mbwbest,
wbwbest type s032-wbwbest,
atwrt type cawn-atwrt,
END OF itab_final.
select-options:s_matnr for s031-matnr.
start-of-selection.
select matnr lgort werks spmon magbb wagbb azubb aagbb
from s031 into table itab1
where matnr in s_matnr.
if not itab1[] is initial.
select matnr maktx from makt into table itab2 for all entries in itab1 where matnr = itab1-matnr.
if not itab2[] is initial.
select matnr werks ekgrp from marc into table itab3 for all entries in itab2 where matnr = itab2-matnr.
if not itab3[] is initial.
select matnr werks mbwbest wbwbest from s032 into corresponding fields of table itab4 for all entries in itab3 where matnr = itab3-matnr.
*if not itab4[] is initial.
select atwrt from cawn into corresponding fields of table itab5.*
endif.
endif.
endif.
endif.
end-of-selection.
loop at itab3.
itab_final-matnr = itab3-matnr.
read table itab2 with key matnr = itab3-matnr.
if sy-subrc = 0.
itab_final-maktx = itab2-maktx.
read table itab1 with key matnr = itab2-matnr.
if sy-subrc = 0.
itab_final-lgort = itab1-lgort.
itab_final-werks = itab1-werks.
itab_final-spmon = itab1-spmon.
itab_final-magbb = itab1-magbb.
itab_final-wagbb = itab1-wagbb.
itab_final-azubb = itab1-azubb.
itab_final-aagbb = itab1-aagbb.
endif.
endif.
itab_final-ekgrp = itab3-ekgrp.
read table itab4 with key matnr = itab3-matnr.
if sy-subrc = 0.
itab_final-mbwbest = itab4-mbwbest.
endif.
itab_final-wbwbest = itab4-wbwbest.
append itab_final.
clear itab_final.
endloop.
WRITE: /2 'material', 23 'storagelocation',29 'plant',35 'date',44 'val.stock.issue',66 'val.stock.issue.value',86 'no.of.stock.receipts',97 'no.of.stock.issues',150 'material.des', 160 'pur.group',190 'stock.val',210 'stock.quan'.
ULINE.
loop at itab_final.
WRITE: /2 itab_final-matnr, 23 itab_final-lgort,29 itab_final-werks,35 itab_final-spmon,44 itab_final-magbb,66 itab_final-wagbb,86 itab_final-azubb,97 itab_final-aagbb,
150 itab_final-maktx, 160 itab_final-ekgrp,190 itab_final-wbwbest,210 itab_final-mbwbest,itab_final-atwrt.
ENDLOOP.
Thanks®ds,
Sree.Hi sree,
take join between s031-sptag ,ausp-datuvthen fetch records based on this condition.(itab1)
After retrieve records based on join condition between
ausp-atinn,ausp-adzhl and cawn-atinn,cawn-adzhl.(itab2)
Retrieve records using for all entries bet first join condition and second join condition.
use for all entries between itab1 and itab2.
it will work surely.
reaward points -
Joining table in GRC 10 Process Control
Hi,
I am trying to create a new Data Source in GRC 10 Process Control. I need to join tables AGR_1251 (main table) and AGR_USERS. I am selecting AGR_1251 as main table. However, nothing comes up when I try to select AGR_USERS as 'Related Table'. On searching AGR_USERS , the system does not return any tables. Both are transparent tables and hence can be joined. I tried using both 'Reference Tables' as well as 'Dependent Tables' .
Can you also explain the difference between 'Reference Tables' and 'Dependent Tables'.
Regards,Hi Amarnath,
tables is used to provide the table for the CURR(currency) or QUAN (quantity) fields.
In your case you want to join tables via foreign key(s) and therefore will have to use dependant tables.
The search for table AGR_USERS as dependant table for AGR_1251 will not return anything since the only table
referred as check table (for a foreign key) in AGR_1251 is AGR_DEFINES.
I would suggest to build your query based on defined check tables (see se11) of the needed tables (in this case AGR_DEFINE is the common point of both AGR_USERS & AGR_1251).
Kind regards,
Pascal -
Joining tables with SQL in Crystal XI
I am new to Crsytal Reports. I want to join 2 tables using a formula, which I am trying to do in SQL. I created a simple test report and I can get it to work if I don't put any fields on the report from the joined table. ie - if I just use fields from "sal-rep" the report works. As soon as I add a field from "freight" (my joined table) the report will not display anything. (but I don't get any error messages - just a blank report). Here is my SQL:
SELECT "sal-rep"."full-name","sal-rep"."invoice-nbr","freight"."misc-charge-ammount" FROM "PUB"."sal-rep" INNER JOIN "PUB"."FREIGHT" ON ("sal-rep"."invoice-nbr"="freight"."invoice-nbr") WHERE "sal-rep"."invoice-nbr"='0000189957'I got it to work!!! This is the SQL I used -
SELECT "sal_rep"."full-name", "sal_rep"."invoice-nbr", "freight"."misc-charge-ammount", "freight"."invoice-date"
FROM "PUB"."freight" "freight" INNER JOIN "PUB"."sal-rep" "sal_rep" ON ("freight"."invoice-nbr"="sal_rep"."invoice-nbr") AND ("freight"."invoice-date"="sal_rep"."inv-date")
WHERE "sal_rep"."invoice-nbr"='0000189957'
Now when I look at the Table used in Database expert it lists - Command and Freight.
Before it was listing Command and Sal-Rep.
Not sure I understand why, but at least it's working.
thanks for your help - really appreciated! -
Procedure fails to compile, because of "Order By" on join table
I am trying to convert a working script into a procedure. The script works fine, but when placed in a procedure, I get the following error:
[Error] Syntax check (4: 71): ERROR line 4, col 71, ending_line 4, ending_col 75, Found 'order', an alias is not allowed here (reserved for XMLCOLATTVAL, XMLFOREST and XMLATTRIBUTES only)
I am essentially trying to make sure that the values are ordered chronologically when placed into the string. Any ideas on why this fails as a procedure or how to ensure the chronological ordering?
I have also noticed that this error does not occur if I am only querying one table (no join, no order by other table field).
The Order By columns are unique to the second table. Aliasing doesn't help.
Jason
CREATE OR REPLACE PROCEDURE AHSANALYTICS.delme_jjs IS
tmpVar varchar2(3000);
BEGIN
SELECT collect_to_string(CAST(COLLECT(TO_CHAR(cs_description) order by CL_DATE_REQUESTED desc) AS collect_table),' >> ') AS cs_description_collect
into tmpvar
FROM f_consul_link f_consul_link,
f_consultations f_consultations
WHERE f_consul_link.cl_pp_sequ = 2973968 AND
f_consul_link.cl_cs_sequ = f_consultations.cs_sequ (+)
GROUP BY cl_pp_sequ;
dbms_output.put_line('tmpvar = '||tmpvar);
END delme_jjs;
/But the same code (minus the INTO) works fine as a script
SELECT collect_to_string(CAST(COLLECT(TO_CHAR(cs_description) order by CL_DATE_REQUESTED ASC, CL_SEQU ASC) AS collect_table),' >> ') AS cs_description_collect
FROM f_consul_link f_consul_link,
f_consultations f_consultations
WHERE f_consul_link.cl_pp_sequ = 2973968 AND
f_consul_link.cl_cs_sequ = f_consultations.cs_sequ (+)
GROUP BY cl_pp_sequ
;The "collect_to_string" function is this:
CREATE OR REPLACE FUNCTION AHSANALYTICS.collect_to_string (
nt_in IN collect_table,
delimiter_in IN VARCHAR2 DEFAULT ','
This function helps to concatenate a set of strings into a single field.
Author : http://oracle101.blogspot.com/2008/08/oracle-collect-function.html
Parameters : collect_table and delimiter_in
Created Date : 2011-Jan-10
Example Script : CREATE OR REPLACE TYPE collect_table AS TABLE OF VARCHAR2 (4000);
SELECT
MAX(pp_sequ)
, MAX(RC.CONS_SEQ) AS ED_CONSULTS
, collect_to_string(CAST(COLLECT(RC.CONSULT_GROUP) AS collect_table),' >> ') AS temp123
, MIN(RC.CONSULT_REQUESTED_DT) AS ED_FIRST_CONSULT_DT
FROM HSA_TGT.redis_consults rc
WHERE
PP_SEQU = 1183707
GROUP BY pp_sequ;
Change History :
yyyy-mmm-dd Author Description
2011-Jan-10 JJS Creation of script
RETURN VARCHAR2
IS
v_idx PLS_INTEGER;
v_str VARCHAR2 (32767);
v_dlm VARCHAR2 (10);
BEGIN
v_idx := nt_in.FIRST;
WHILE v_idx IS NOT NULL
LOOP
v_str := v_str || v_dlm || nt_in (v_idx);
v_dlm := delimiter_in;
v_idx := nt_in.NEXT (v_idx);
END LOOP;
RETURN v_str;
END collect_to_string;
/Jason_S wrote:
David,
The issue only seems to arise when there are two tables joined, and the order by is based on the 'other' table.
JasonNot here....
SQL> create table another_table
2 ( id number
3 )
4 /
SQL> declare
2
3 tmpvar varchar2(100);
4
5 BEGIN
6 SELECT collect_to_string
7 ( CAST
8 ( COLLECT
9 ( TO_CHAR(cs_description)
10 order by id desc
11 ) AS collect_table
12 ),
13 ' >> '
14 ) AS cs_description_collect
15 into tmpvar
16 FROM f_consul_link f_consul_link,
17 another_table
18 WHERE f_consul_link.cl_pp_sequ = 2973968
19 AND
20 f_consul_link.cl_pp_sequ = another_table.id (+)
21 GROUP BY cl_pp_sequ;
22 END ;
23 /
PL/SQL procedure successfully completed.
SQL> declare
2
3 tmpvar varchar2(100);
4
5 BEGIN
6 SELECT collect_to_string
7 ( CAST
8 ( COLLECT
9 ( TO_CHAR(cs_description)
10 order by id desc
11 ) AS collect_table
12 ),
13 ' >> '
14 ) AS cs_description_collect
15 into tmpvar
16 FROM f_consul_link f_consul_link,
17 another_table
18 WHERE f_consul_link.cl_pp_sequ = 2973968
19 AND
20 f_consul_link.cl_pp_sequ = another_table.id
21 GROUP BY cl_pp_sequ;
22 END ;
23 /
declare
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at line 6Again, maybe you could post your create table statements and full version of oracle....although it is fairly academic given the alternative ways to aggregate strings in the links provided.
David
Maybe you are looking for
-
All desktop items missing, even with 2 monitors!
When I turn my Power Mac G3 on, all my desktop items are missing.. everything. I thought that the monitor setting got changed to "2 monitors" and the desktop items were set to be on the other monitor, so I hooked up a second one, but I'm still missin
-
I notice when I leave Messages running, it begins to take massive amounts of RAM. I have 16 GB of RAM on my iMac, and I just sat at my computer see Messages using 12.58 GB of RAM according to Activity Monitor. That is absurd! It made my computer c
-
Help Required for populating proift center values in FS10N
Hi SAPientz , I am working on dynamic selection to populate screen fields of transaction FS10N from my program. I am developing a custom program where by when user enters G/L account number, Company code and fiscal year it submits the value to fields
-
Barely audible sound from X-fi to Z5500s
(Barely audible sound from X-fi to Z5500s? For the past few weeks every other day or so after turning on my computer I get barely audible sound from my computer speakers (Z5500s) connected through the 6 ch direct. I can make out music or whatever it
-
Update on Safari 3.2 Fixes
http://www.macfixit.com/article.php?story=2008111400261368