Problem in select query in QUERY INFOSET
Hi All
I have requirement to find the sales text maintained for sales order in mass in production. By using the FM READ_TEXT i can pass the necessary values to get the sales text. We dont want to write a program and then transprot to P01. So what i did in SQ02 i create a infoset and worte code in the infoset. Here i am facing the problem that in the select query where clause what ever on the selection screen values, for that the query need to fetch the records. But selection screen is dymically selected based on SQVI t-code.
In select query if i write like this
SELECT TDOBJECT TDNAME TDID TDSPRAS
FROM STXH
INTO TABLE IT_TEXT_DETAIL
WHERE TDOBJECT EQ C_KNMT .
Here i have hardcoded KNMT so it will fetch only that value irrespective of any values on the selection screen. How to get the values based on the selection screen. I debugged the query it automatically generates the code for selection screen which i am not able to pass in the program.
SAP has generated this code
select-options SP$00004 for STXH-TDOBJECT.
select-options SP$00005 for STXH-TDNAME.
select-options SP$00006 for STXH-TDID.
If i pass SP$00004 on where clause its giving me error. So how to pass it dynamically. Waiting for experts answer.
Regards
Vijay
Hi Vijay,
In this case concatenate 'TDOBJECT' 'EQ' C_KNMT INTO V_WHERE (Say) SEPERATED BY SPACE.
DATA : v_where(90) type c.
clear v_where.
CONCATENATE 'TDOBJECT'
'EQ'
C_KNMT
INTO V_WHERE
SEPERATED BY SPACE.
SELECT TDOBJECT TDNAME TDID TDSPRAS
FROM STXH
INTO TABLE IT_TEXT_DETAIL
WHERE (V_WHERE) .
Try to do this and let me know in case of any.
Regards,
SRinivas
Similar Messages
-
Performance Problem in Select query
Hi,
I have performance Problem in following Select Query :
SELECT VBELN POSNR LFIMG VRKME VGBEL VGPOS
FROM LIPS INTO CORRESPONDING FIELDS OF TABLE GT_LIPS
FOR ALL ENTRIES IN GT_EKPO1
WHERE VGBEL = GT_EKPO1-EBELN
AND VGPOS = GT_EKPO1-EBELP.
as per trace i have analysed that it is fetch the complete table scan from the LIPS table and table contants almost 3 lakh records.
Kindly Suggest what we can do to optimize this query.
Regards,
Harshtypes: begin of line,
vbeln type lips-vbeln
posnr type lips-posnr
lfimg type lips-lfimg
vrkme type lips-vrkme
vgbel type lips- vgbel
vgpos type lips-vgpos
end of line.
data: itab type standard table of line,
wa type line.
IF GT_EKPO1[] IS NOT INITIAL.
SELECT VBELN POSNR LFIMG VRKME VGBEL VGPOS
FROM LIPS INTO TABLE ITAB
FOR ALL ENTRIES IN GT_EKPO1
WHERE VGBEL = GT_EKPO1-EBELN
AND VGPOS = GT_EKPO1-EBELP.
ENDIF. -
Hi All,
i_dfkkko-xblnr
IF NOT i_dfkkko[] IS INITIAL .
SELECT opbel
belnr
FROM erchc
INTO TABLE i_erchc1
FOR ALL ENTRIES IN i_dfkkko
WHERE opbel EQ i_dfkkko-xblnr.
ENDIF.
I am using the above select query.problem is when i put the value
of i_dfkkko-xblnr by going to the table erchc i am getting the record.But this qury is not resulting any value.
i have checked in debug mode copied the value of xblnr of i_dfkkko
and went to erchc table and passed to opbel of erchc i got the reords.
can anybody pls help..
Rgds,
SaiHi,
The database would be having the value with leading zeroes.
Use FM "CONVERSION_EXIT_ALPHA_INPUT" to conver the values & then pass to select query.
_dfkkko-xblnr
IF NOT i_dfkkko[] IS INITIAL .
loop at i_dfkkko.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
VALUE(INPUT) = i_dfkkko-xblnr
IMPORITNG
VALUE(OUTPUT) = i_dfkkko-xblnr.
modify i_dfkkko.
endloop.
SELECT opbel
belnr
FROM erchc
INTO TABLE i_erchc1
FOR ALL ENTRIES IN i_dfkkko
WHERE opbel EQ i_dfkkko-xblnr.
ENDIF. -
Hi Friends
I am using a table a981 and fetching data in internal table but the table has a fieil Country whose technical name is ALAND in dev and LAND1 in production.Now i cannot use LAND1 as it wont let me to activate the report and if i use ALAND i cannot move the request to production as it fails. So how can i achive dynamic table field in the select query based on server.My query is-
select kschl
wkreg
matnr
knumh
from a981 into corresponding fields of table it_a981
for all entries in it_marc where matnr = it_marc-matnr
and kschl in ('MWST','ZSER')
and aland = 'IN'
and datab le sy-datum
and datbi ge sy-datum.
I need to make aland dynamic.Pls suggestIf you insist on having a workaround, you could always create dynamic WHERE conditions.
DATA: cond TYPE string.
IF sy-sysid EQ <your dev sysid>.
cond = 'matnr = it_marc-matnr
and kschl in (''MWST'',''ZSER'')
and datab le sy-datum
and datbi ge sy-datum'
and land1 = ''IN''.
ELSE.
cond = 'matnr = it_marc-matnr
and kschl in (''MWST'',''ZSER'')
and datab le sy-datum
and datbi ge sy-datum'
and aland = ''IN''.
ENDIF.
select kschl
wkreg
matnr
knumh
from a981 into corresponding fields of table it_a981
for all entries in it_marc where (cond).
Kyle -
Time out problem for select query
I am fetching data from BKPF for my report.
I have written following query.But this query always time out.
SELECT
BUKRS
BELNR
GJAHR
BLART
BLDAT
BUDAT
MONAT
XBLNR
BKTXT
WAERS
KURSF
HWAER
FROM BKPF
INTO TABLE I_BKPF
WHERE BUKRS IN S_BUKRS
AND BELNR IN S_BELNR
AND GJAHR IN S_GJAHR
AND BLART IN S_BLART
AND BLDAT IN S_BLDAT
AND BUDAT IN S_BUDAT
AND MONAT IN S_MONAT
AND CPUDT IN S_CPUDT
AND BSTAT = SPACE.
So please suggest me solution.Hi..
1) Try to make Some of the Fields such as BUKRS , GJAHR as PARAMETERS so that ROWS are restrited mostly.
2) Make fields like BLDAT and BUDAT as OBLIGATORY if possible.
3) And in the SELECT query add the PACKAGE SIZE addition.
<b>Reward if Helpful.</b> -
Offset problem in select query
Hi experts,
I have a select query , in my where condition , comparing fields types are different
following is my select query
SELECT spras prctr ktext FROM cepct INTO CORRESPONDING FIELDS OF TABLE it_cepct FOR ALL ENTRIES IN it_vbsegd
WHERE prctr = it_vbsegd-bupla .
here prctr length = 10
and bupla length = 4.
we can give offset after "=" sign, but i want to use on prctr field, could anybody please give me some idea to achieve this.
thanks in advanceHi,
created another internal table it_tab to get the result which you wanted.
DATA : it_cepct TYPE TABLE OF cepct,
it_vbsegd TYPE TABLE OF vbsegd,
wa_vbsegd type vbsegd.
TYPES : BEGIN OF ty_tab,
bupla(10),
END OF ty_tab.
DATA : it_tab TYPE TABLE OF ty_tab,
lv_bupla(10).
select * UP TO 2 ROWS FROM vbsegd INTO TABLE it_vbsegd.
loop at it_vbsegd INTO wa_vbsegd.
UNPACK wa_vbsegd-bupla to lv_bupla.
append lv_bupla to it_tab.
CLEAR : lv_bupla,wa_vbsegd.
ENDLOOP.
SELECT spras prctr ktext FROM cepct INTO CORRESPONDING FIELDS OF TABLE it_cepct FOR ALL ENTRIES IN it_tab
WHERE prctr = it_tab-bupla. -
Reg: Problem in select query..
Hi all,
I want to write a select query for table COEP. Like if you open SE16 and give KSTAR with S5* we will get full data related to S5xxxxx. Same like I am trying to write for select.
TYPES: BEGIN OF T_COEP,
BELNR TYPE CO_BELNR, " PLANT
PERIO TYPE CO_PERIO, " Period
KSTAR TYPE KSTAR, " Cost Element
WERKS TYPE WERKS_D, " PLANT
MATNR TYPE MATNR, " Material Number
END OF T_COEP.
data: I_COEP TYPE STANDARD TABLE OF T_COEP,
W_COEP TYPE T_COEP.
SELECT BELNR " DOCUMENT NO
PERIO " Period
KSTAR " Cost Element
WERKS " PLANT
MATNR " Material Number
FROM COEP
INTO CORRESPONDING FIELDS OF TABLE I_COEP
WHERE KSTAR = C_S5.(HERE want I need give)*
LOOP AT I_COEP INTO W_COEP.
WRITE:/ W_COEP-BELNR, W_COEP-PERIO, W_COEP-KSTAR,
W_COEP-WERKS, W_COEP-MATNR.
ENDLOOP.
Moderator message - Please search before asking - post locked
Edited by: Rob Burbank on May 15, 2009 1:34 PMHi,
write the code like this..
SELECT BELNR " DOCUMENT NO
PERIO " Period
KSTAR " Cost Element
WERKS " PLANT
MATNR " Material Number
FROM COEP
INTO CORRESPONDING FIELDS OF TABLE I_COEP
*WHERE KSTAR = C_S5*.(HERE want I need give)*
where kstar in 'c_s%'. "write % it will acts like *
Regards,
Prabhudas -
Problem is select query.
Hello SDNites,
I have a req where I need to use select query to fetch data. But the conditions which is to be placed in this select query has 3 checkboxes corresponding to the same field. Either of them can be selected at a time. Please let me know how can we put this condition effectively in one select query.
Thanks,
AbhishekHi Abhishek,
Depending on your check box selection u can concatenate the string for where ckause....
For eg:-
concatenate `'` 'A' `'` into fs.
concatenate `'` 'F' `'` into fs1.
if cb1 = 'X' and CB2 = 'X'.
CONCATENATE 'bstyp' '=' FS 'OR' 'bstyp' '=' FS1 INTO FS SEPARATED BY SPACE.
endif.
select * from dbtab into table itab where (fs).
depending on ur check box selection u can change ur VARIABLE FS to be used in where clause....... But u just need to use single select query. -
Problem using SELECT-OPTIONS in an InfoSet with a field of data type UNIT.
I have created a simple InfoSet that links MARA with MARM. In the 'Selections' section of the InfoSet I have a variable named 'ZMEINH' defined as
Description: UOM
Selection Text: UOM
Format FOR: MARM-MEINH
EXTRAS: DEFAULT 'PAC' OPTION EQ SIGN I.
When I ran a query to allow selections on the MEINH field, instead of 'PAC' being the default, there was "***" showing in the UOM selection and if I attempted to execute the query it gave me a message that "Unit *** is not created in languague EN'. If I overide the "***" and enter 'PAC', I get the list of records that I expect.
I assume this is because MEINH has a data type of "UNIT".
How can I do a conversion so I can define a default value 'PAC' for MARM-MEINH in the infoSet that will carry through to any queries I created.
Thank you very much for any help.
Richard SalisburyThank you both for you help!
In our T006 there actually is a PAC and not a PAK. The T006A had as DE-PAK though.
I had this same type of language problem when trying to match an "order type". German is the "base" language in our system so maybe that means that raw data is stored with the German constant?
Anyway, I changed it to PAK and it works. When under a time schedule, that is what counts.
Thank you again for the quick response!
Richard Salisbury -
Hi,
Thanks to all oracle mem
I have a problem when i select the row from table with null
I want return the result as 1 when i the values are null
select nvl(MC/(recd_qty*swb_qty,3) MC_VAL from sys_prlot_sales
if the values of recd_qty ,swb_qty are null it will return 1
so how can modify the above query please reply
Thanksnvl(MC/(recd_qty*swb_qty,3)Don't understand what the 3 ? And it seems that a ) was missed...
Nicolas. -
Problem with select query in search
Hi,
Here i am using MYSQL database and when i am insertind date to database it is saving like '2009-11-10 00:00:00' and when i used to dispaly this in dateformat as '11/10/2009' .
here is the problem occurs , when i write a search query as
select recruitername,interviewdate ,skillset
from details
where interviewdate = #form.interviewdate#
i am getting problem with date . would u please help me how to solve this issue .Try to use DateFormat
select recruitername,interviewdate ,skillset
from details
where interviewdate = #DateFormat(form.interviewdate, "yyyy-dd-mm")# -
Problem with select query (results cant b displayed)
SELECT url,SUM(data_received) xyz FROM logs GROUP BY url ORDER BY xyz desc
when i triedthe above query in the worksheet it works fine but when i write same query in code i get this error.
myjsp page has this code.
<%while (rset.next())
out.println("<tr>");
out.println("<td>" +
rset.getString(1) + "</td><td>" +
rset.getInt(2) + "</td><td> " +
"</td>");
out.println("<tr>");
%>
This is the error
500 Internal Server Error
java.sql.SQLException: Invalid column name at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:175) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:240) at oracle.jdbc.driver.OracleStatement.get_column_index(OracleStatement.java:3201) at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1880) at oracle.jdbc.driver.ScrollableResultSet.findColumn(ScrollableResultSet.java:1308) at oracle.jdbc.driver.OracleResultSet.getInt(OracleResultSet.java:1618) at list_action._jspService(_list__action.java:67) [list_action.jsp] at com.orionserver[Oracle Containers for J2EE 10g (10.1.3.0.0) ].http.OrionHttpJspPage.service(OrionHttpJspPage.java:60) at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:416) at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:478) at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:401) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:719) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:376) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:870) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:218) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:119) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:112) at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260) at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:230) at oracle.oc4j.network.ServerSocketAcceptHandler.access$800(ServerSocketAcceptHandler.java:33) at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:831) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303) at java.lang.Thread.run(Thread.java:595)
please helpit is better to use into table ....itab.
dont go for joins if u r joining four tables .......
it is better to for all entries.
SELECT aauart awerks akdauf akdpos
bftrmi baufnr bstlbez baufpl
blead_aufnr bprodnet
FROM aufk AS a
INNER JOIN afko AS b
ON baufnr EQ aaufnr
INTO TABLE i_data1
WHERE a~auart IN s_auart
AND a~kdauf IN s_vbeln
AND a~werks EQ p_werks
AND b~aufnr IN s_aufnr
AND b~ftrmi IN s_ftrmi.
if i_data1[] is not initial .
if any sorting criteria is required based on primary keys write the sort statement here.
select crueck crmzhl
cvornr carbid clmnga cxmnga
crmnga cism04 cism05 cbudat
d~kunnr
e~arbpl
FROM afru AS c inner join vbak AS d
ON caufnr EQ aaufnr innerjoin crhd AS e
like this u need to do...........................
u have joined around five tables ...definetly that wont work
endif. -
So, I work on a legacy CF web site and there are numerous SELECT * FROM USERS_TABLE queries all over the site.
Well, we changed the structure of said table in the database on our Testing and Staging sites, with no issues.
When we pushed up to our production environment and changed the structure of the production DB table, the server kept kicking back "Value can not be converted to requested type."
After doing some searching out there, it looks like CF caches the structure of the table, and you either have to restart CF to clear it, or rename and then name-back the DSN to fix the issue.
http://www.bennadel.com/blog/194-ColdFusion-Query-Error-Value-Can-Not-Be-Converted-To-Requ ested-Type.htm
That said, this doesn't happen in our testing and staging environments - so what would be the difference?
Is there some setting I need to change in the CF Admin to keep this from happening again?Also, if you can use a Stored Procedure to retrieve the data, do so. Standard queries gets all the information, anyway, chokes bandwidth passing it all to the CF server, and forces the CF server to filter, sort, and format the data. SPs tell the db server to get ONLY the data requested, and forces the db server to filter and sort the data, leaving only formatting to the CF server.
That's not true. The only time CF messes with data returned from the DB is if there's a maxrows attribute, and the record set returnded from the DB has more than that number of records... which causes CF to truncate the recordset to the correct size before returning it. The DB might or might not stop sending rows down to CF after CF says "yeah, I've got all I want now".
Other than that, for all intents and purposes all CF does with the SQL is pass it to the DB and wait for an answer. The only thing it does to the returned data is to create a CF record set ("query") with it... this does not involve any filtering and sorting.
Adam -
What is the problem in this code (problem in select query)
Just need your help in solving one issue. In the below code one query which is highlighted
Select statement not working means cursor directly goes to the endselect .means these two statements not executed.
CLASS cl_abap_container_utilities DEFINITION LOAD.
CALL METHOD cl_abap_container_utilities=>read_container_c
I am attaching that code with this mail. Please do the needful help.
*& Report ZEOU_RG1 *
REPORT zeou_rg1 LINE-SIZE 400.
Purpose : RG1 Report driver
Remarks :
constants
INCLUDE j_2icons.
type declerations
INCLUDE j_2isdef.
table definitions and internal tables
INCLUDE j_2iddef.
INCLUDE <icon>.
DATA: $plant TYPE bp_addr_typ,
$lincnt LIKE sy-linct,
m_date LIKE j_1ipart2-budat,
m_chapid LIKE j_1iexcdtl-chapid,
m_matform LIKE j_1irg1-matform,
m_bedrate LIKE j_1irg1-bedrate,
tot_op_bal LIKE j_1irg1-menge,
tot_qty_mnfr LIKE j_1irg1-menge,
tot_total_qty_mnfr LIKE j_1irg1-menge,
tot_remv_home LIKE j_1irg1-menge,
tot_remv_hval LIKE j_1irg1-exbas,
tot_remv_expr LIKE j_1irg1-menge,
tot_remv_eval LIKE j_1irg1-exbas,
tot_remv_expb LIKE j_1irg1-menge,
tot_remv_othr LIKE j_1irg1-menge,
tot_remv_opur LIKE j_1irg1-menge,
tot_duty_amt LIKE j_1irg1-exbed,
tot_cb_fr LIKE j_1irg1-exbed,
tot_cb_br LIKE j_1irg1-exbed.
DATA: t_rg1_cons TYPE rg1_typ OCCURS 0 WITH HEADER LINE.
FIELD-SYMBOLS: <x_extrctdata> TYPE c,
<x_rg1> TYPE rg1_typ,
<x_part1typ> TYPE part1_typ.
DATA : it_j_1iexchdr TYPE j_1iexchdr OCCURS 0 WITH HEADER LINE,
wa_j_1iexchdr TYPE j_1iexchdr,
it_j_1iexcdtl TYPE j_1iexcdtl OCCURS 0 WITH HEADER LINE,
wa_j_1iexcdtl TYPE j_1iexcdtl.
selection screen
PARAMETERS: p_exgrp LIKE j_1iexchdr-exgrp OBLIGATORY MEMORY ID j2i,
p_stdate LIKE sy-datum OBLIGATORY,
p_endate LIKE sy-datum OBLIGATORY.
*SELECTION-SCREEN SKIP 1.
*SELECTION-SCREEN BEGIN OF BLOCK 4 WITH FRAME TITLE TEXT-001.
*SELECTION-SCREEN BEGIN OF LINE.
*SELECTION-SCREEN POSITION 01.
*PARAMETERS: P_INDI RADIOBUTTON GROUP 57F4 DEFAULT 'X'.
*SELECTION-SCREEN COMMENT (25) TEXT-002.
*SELECTION-SCREEN END OF LINE.
*SELECTION-SCREEN BEGIN OF LINE.
*SELECTION-SCREEN POSITION 01.
*PARAMETERS: P_CONS RADIOBUTTON GROUP 57F4.
*SELECTION-SCREEN COMMENT (25) TEXT-003.
*SELECTION-SCREEN END OF LINE.
*SELECTION-SCREEN END OF BLOCK 4.
INITIALIZATION.
AT SELECTION-SCREEN.
SELECT SINGLE *
FROM j_1iexgrps
WHERE j_1iexcgrp = p_exgrp.
IF sy-subrc NE 0.
MESSAGE e399(8i) WITH p_exgrp.
ENDIF.
*check company code
SELECT SINGLE *
FROM t001k
WHERE bwkey = j_1iexgrps-j_1iwerks.
IF sy-subrc NE 0.
MESSAGE e518(8i) WITH 'the' 'plant' j_1iexgrps-j_1iwerks.
ENDIF.
<b>START-OF-SELECTION.
CLEAR: j_1irg1, j_2icomp.
retrieve layout name and details
SELECT SINGLE *
FROM J_2ILAYCTR
WHERE BUKRS = T001K-BUKRS
AND REGISTER = C_RG1
AND LAYOUTNR = 1.
IF SY-SUBRC NE 0.
MESSAGE E635(8I) WITH T001K-BUKRS C_RG1.
ENDIF.
SET COUNTRY 'IN'.
REFRESH t_reciepts.
report driver logic
SELECT *
FROM j_2iextrct
WHERE exgrp = p_exgrp
AND budat >= p_stdate
AND budat <= p_endate
AND register = c_rg1
ORDER BY budat keyid.
assign J_2IEXTRCT-EXTRCTDATA to <x_extrctdata> casting.
assign T_RG1 to <x_rg1> casting.
<x_rg1> = <x_extrctdata>.
CLASS cl_abap_container_utilities DEFINITION LOAD.
CALL METHOD cl_abap_container_utilities=>read_container_c
EXPORTING
im_container = j_2iextrct-extrctdata
IMPORTING
ex_value = t_rg1
EXCEPTIONS
illegal_parameter_type = 1
OTHERS = 2.
MOVE J_2IEXTRCT-EXTRCTDATA TO T_RG1.
APPEND t_rg1.
ENDSELECT.
DESCRIBE TABLE t_rg1 LINES $lincnt.
IF $lincnt = 0.
MESSAGE e548(8i) WITH p_stdate p_endate.
ENDIF.</b>
PERFORM PLANT_AND_EXCISE_DTLS USING P_WERKS.
PERFORM plant_and_excise_dtls USING j_1iexgrps-j_1iwerks.
MOVE : 'ZJ_2I_RG1' TO j_2ilayctr-layoutname.
SORT t_rg1 BY chapid matnr cpudt .
open form
PERFORM open_form USING j_2ilayctr-layoutname j_2ilayctr-noofcopies "J_2ILAYCTR-LAYOUTNAME
j_2ilayctr-outdevice true.
process extract data and write
IF P_INDI = 'X'.
PERFORM get_data_and_write.
ELSEIF P_CONS = 'X'.
PERFORM RG1_PRINT_CONS.
PERFORM GET_DATA_AND_WRITE_CONS.
ENDIF.
close form
PERFORM close_form.
F O R M S
INCLUDE j_2ilayo.
*& Form GET_DATA_AND_WRITE
Purpose : Logic to print RG1 report
FORM get_data_and_write.
DATA: save_matnr LIKE mara-matnr.
CLEAR: j_1irg1, j_2icomp, save_matnr.
SELECT * FROM j_1iexchdr INTO TABLE it_j_1iexchdr
WHERE exgrp = p_exgrp
AND budat >= p_stdate
AND budat <= p_endate.
SORT it_j_1iexchdr BY cpudt docno.
LOOP AT it_j_1iexchdr.
SELECT * FROM j_1iexcdtl INTO wa_j_1iexcdtl
WHERE docno = it_j_1iexchdr-docno.
APPEND wa_j_1iexcdtl TO it_j_1iexcdtl.
ENDSELECT.
ENDLOOP.
clear wa_j_1iexcdtl.
SORT it_j_1iexcdtl BY chapid matnr cpudt docno.
LOOP AT t_rg1.
CLEAR: j_1irg1, j_2icomp.
assign header fields
j_2icomp-stdate = p_stdate.
j_2icomp-endate = p_endate.
IF save_matnr NE t_rg1-matnr.
fill header line with matnr, description, chapterid and unit
j_1irg1-chapid = t_rg1-chapid.
mara-matnr = t_rg1-matnr.
marav-maktx = t_rg1-maktx.
mara-meins = t_rg1-meins.
save_matnr = t_rg1-matnr.
IF sy-tabix NE 1.
j_2icomp-new_page = true.
ELSE.
j_2icomp-new_page = false.
ENDIF.
ELSE.
j_2icomp-new_page = false.
ENDIF.
PERFORM write_form USING element-spac function-set
typ-body window-main .
determine line to display viz. manufacture entry/removal entry
IF t_rg1-matform = c_packed.
j_2icomp-rg1_p_l = c_packed.
ELSEIF t_rg1-matform = c_loose.
j_2icomp-rg1_p_l = c_loose.
ENDIF.
j_1irg1-cpudt = t_rg1-cpudt.
j_2icomp-op_qty = t_rg1-op_bal.
j_2icomp-mf_qty = t_rg1-qty_mfr.
j_2icomp-to_qty = t_rg1-total.
j_2icomp-cl_fin = t_rg1-cl_bal_fn.
j_2icomp-cl_bon = t_rg1-cl_bal_bn.
j_2icomp-remarks = t_rg1-remarks.
j_2icomp-h_menge = t_rg1-h_menge.
j_2icomp-h_value = t_rg1-h_value.
j_2icomp-e_menge = t_rg1-e_menge.
j_2icomp-e_value = t_rg1-e_value.
j_2icomp-e_menge_bn = t_rg1-e_menge_bond.
j_2icomp-o_menge = t_rg1-o_menge.
j_2icomp-o_purpose = t_rg1-o_purpose.
j_2icomp-o_pur_meng = t_rg1-o_pur_menge.
j_1irg1-bedrate = t_rg1-bedrate.
j_1irg1-exbed = t_rg1-bedamt.
j_2icomp-cl_fin = t_rg1-cl_bal_fn.
j_2icomp-cl_bon = t_rg1-cl_bal_bn.
j_2icomp-remarks = t_rg1-remarks.
READ TABLE it_j_1iexcdtl WITH KEY cpudt = t_rg1-cpudt
chapid = t_rg1-chapid
matnr = t_rg1-matnr.
IF sy-subrc = 0.
get duties for issues only.
IF t_rg1-rcptissrsn = 'IPD'
OR t_rg1-rcptissrsn = 'IWD'
OR t_rg1-rcptissrsn = 'IDH'
OR t_rg1-rcptissrsn = 'IDE'
OR t_rg1-rcptissrsn = 'IWE'
OR t_rg1-rcptissrsn = 'IWT'
OR t_rg1-rcptissrsn = 'IWO'.
READ TABLE it_j_1iexchdr WITH KEY exnum = t_rg1-rdoc1
trntyp = 'DLFC'
cpudt = t_rg1-cpudt.
READ TABLE it_j_1iexcdtl WITH KEY docno = it_j_1iexchdr-docno
cpudt = it_j_1iexchdr-cpudt
trntyp = 'DLFC'
matnr = t_rg1-matnr.
docyr = it_j_1iexchdr-docyr
IF IT_j_1iexchdr-expind <> 'B'
and it_j_1iexchdr-expind <> 'U'
and it_j_1iexchdr-expind <> 'D'
and it_j_1iexchdr-expind <> 'N'
AND T_RG1-h_menge > 0.
and it_j_1iexchdr-expind IS INITIAL.
IF it_j_1iexchdr-censtat = 'P'.
wa_j_1iexcdtl-ecs = it_j_1iexcdtl-ecs.
ENDIF.
IF it_j_1iexchdr-censtat = 'C'.
wa_j_1iexchdr-exbed = it_j_1iexchdr-exbed.
wa_j_1iexchdr-ecs = it_j_1iexchdr-ecs.
wa_j_1iexchdr-censtat = it_j_1iexchdr-censtat.
wa_j_1iexchdr-cpudt = it_j_1iexchdr-cpudt.
wa_j_1iexcdtl-rgplaser = it_j_1iexcdtl-rgplaser.
wa_j_1iexcdtl-rg23aser = it_j_1iexcdtl-rg23aser.
ENDIF.
ENDIF.
endif.
ENDIF.
PERFORM write_form USING element-d function-append
typ-body window-main .
CLEAR : wa_j_1iexchdr, wa_j_1iexcdtl.
ENDLOOP.
ENDFORM. " GET_DATA_AND_WRITE
*& Form GET_DATA_AND_WRITE_CONS
text *
--> p1 text
<-- p2 text
FORM get_data_and_write_cons.
DATA: save_chapid LIKE j_1iexcdtl-chapid.
CLEAR: j_1irg1, j_2icomp, save_chapid.
LOOP AT t_rg1_cons.
CLEAR: j_1irg1, j_2icomp.
assign header fields
j_2icomp-stdate = p_stdate.
j_2icomp-endate = p_endate.
IF save_chapid NE t_rg1_cons-chapid.
fill header line with chapterid
j_1irg1-chapid = t_rg1_cons-chapid.
save_chapid = t_rg1_cons-chapid.
IF sy-tabix NE 1.
j_2icomp-new_page = true.
ELSE.
j_2icomp-new_page = false.
ENDIF.
ELSE.
j_2icomp-new_page = false.
ENDIF.
PERFORM write_form USING element-spac function-set
typ-body window-main .
determine line to display viz. manufacture entry/removal entry
IF t_rg1_cons-matform = c_packed.
j_2icomp-rg1_p_l = c_packed.
ELSEIF t_rg1_cons-matform = c_loose.
j_2icomp-rg1_p_l = c_loose.
ENDIF.
j_1irg1-cpudt = t_rg1_cons-cpudt.
j_2icomp-op_qty = t_rg1_cons-op_bal.
j_2icomp-mf_qty = t_rg1_cons-qty_mfr.
j_2icomp-to_qty = t_rg1_cons-total.
j_2icomp-cl_fin = t_rg1_cons-cl_bal_fn.
j_2icomp-cl_bon = t_rg1_cons-cl_bal_bn.
j_2icomp-remarks = t_rg1_cons-remarks.
j_2icomp-h_menge = t_rg1_cons-h_menge.
j_2icomp-h_value = t_rg1_cons-h_value.
j_2icomp-e_menge = t_rg1_cons-e_menge.
j_2icomp-e_value = t_rg1_cons-e_value.
j_2icomp-e_menge_bn = t_rg1_cons-e_menge_bond.
j_2icomp-o_menge = t_rg1_cons-o_menge.
j_2icomp-o_purpose = t_rg1_cons-o_purpose.
j_2icomp-o_pur_meng = t_rg1_cons-o_pur_menge.
j_1irg1-bedrate = t_rg1_cons-bedrate.
j_1irg1-exbed = t_rg1_cons-bedamt.
j_2icomp-cl_fin = t_rg1_cons-cl_bal_fn.
j_2icomp-cl_bon = t_rg1_cons-cl_bal_bn.
j_2icomp-remarks = t_rg1_cons-remarks.
PERFORM write_form USING element-d function-append
typ-body window-main .
*for grand totals
tot_remv_hval = tot_remv_hval + t_rg1_cons-h_value.
tot_remv_eval = tot_remv_eval + t_rg1_cons-e_value.
tot_duty_amt = tot_duty_amt + t_rg1_cons-bedamt.
ENDLOOP.
*for grand totals
j_2icomp-amount1 = tot_remv_hval.
j_2icomp-amount2 = tot_remv_eval.
j_2icomp-amount3 = tot_duty_amt.
PERFORM write_form USING element-t function-append
typ-body window-footer.
ENDFORM. " GET_DATA_AND_WRITE_CONS
*& Form RG1_PRINT_CONS
text *
--> p1 text
<-- p2 text
FORM rg1_print_cons.
DATA : first_time VALUE on.
SORT t_rg1 BY chapid cpudt.
LOOP AT t_rg1.
IF first_time = on.
m_chapid = t_rg1-chapid.
m_date = t_rg1-cpudt.
m_matform = t_rg1-matform.
m_bedrate = t_rg1-bedrate.
first_time = off.
ENDIF.
IF m_chapid <> t_rg1-chapid.
PERFORM chapid_break.
ELSEIF m_date <> t_rg1-cpudt.
PERFORM date_break.
ENDIF.
Accumulate totals
tot_op_bal = tot_op_bal + t_rg1-op_bal.
tot_qty_mnfr = tot_qty_mnfr + t_rg1-qty_mfr.
tot_total_qty_mnfr = tot_total_qty_mnfr + t_rg1-total.
tot_remv_home = tot_remv_home + t_rg1-h_menge.
tot_remv_hval = tot_remv_hval + t_rg1-h_value.
tot_remv_expr = tot_remv_expr + t_rg1-e_menge.
tot_remv_eval = tot_remv_eval + t_rg1-e_value.
tot_remv_expb = tot_remv_expb + t_rg1-e_menge_bond.
tot_remv_othr = tot_remv_othr + t_rg1-o_menge.
tot_remv_opur = tot_remv_opur + t_rg1-o_pur_menge.
tot_duty_amt = tot_duty_amt + t_rg1-bedamt.
tot_cb_fr = tot_cb_fr + t_rg1-cl_bal_fn.
tot_cb_br = tot_cb_br + t_rg1-cl_bal_bn.
ENDLOOP.
PERFORM chapid_break.
ENDFORM. " RG1_PRINT_CONS
*& Form DATE_BREAK
text *
--> p1 text
<-- p2 text
FORM date_break.
CLEAR t_rg1_cons.
t_rg1_cons-chapid = m_chapid.
t_rg1_cons-cpudt = m_date.
t_rg1_cons-op_bal = tot_op_bal.
t_rg1_cons-qty_mfr = tot_qty_mnfr.
t_rg1_cons-total = tot_total_qty_mnfr.
t_rg1_cons-h_menge = tot_remv_home.
t_rg1_cons-h_value = tot_remv_hval.
t_rg1_cons-e_menge = tot_remv_expr.
t_rg1_cons-e_value = tot_remv_eval.
t_rg1_cons-e_menge_bond = tot_remv_expb.
t_rg1_cons-o_menge = tot_remv_othr.
t_rg1_cons-o_pur_menge = tot_remv_opur.
t_rg1_cons-bedamt = tot_duty_amt.
t_rg1_cons-cl_bal_fn = tot_cb_fr.
t_rg1_cons-cl_bal_bn = tot_cb_br.
t_rg1_cons-matform = m_matform.
t_rg1_cons-bedrate = m_bedrate.
APPEND t_rg1_cons.
tot_op_bal = 0.
tot_qty_mnfr = 0.
tot_total_qty_mnfr = 0.
tot_remv_home = 0.
tot_remv_hval = 0.
tot_remv_expr = 0.
tot_remv_eval = 0.
tot_remv_expb = 0.
tot_remv_othr = 0.
tot_remv_opur = 0.
tot_duty_amt = 0.
tot_cb_fr = 0.
tot_cb_br = 0.
m_date = t_rg1-cpudt.
m_matform = t_rg1-matform.
m_bedrate = t_rg1-bedrate.
ENDFORM. " DATE_BREAK
*& Form CHAPID_BREAK
text
--> p1 text
<-- p2 text
FORM chapid_break.
PERFORM date_break.
m_chapid = t_rg1-chapid.
ENDFORM. " CHAPID_BREAKhi rakesh,
in your first select single * statement you have given WHERE BUKRS = T001K-BUKRS..but at the point of execution, what will be the value stored in t001k-bukrs...i doubt it will be initial....so, store bukrs in a variable or hardcode it.....
in the second select, you hve not given any target work area for the into class...that's y your subrc is 4...specify a target area, where you want the data to be stored... -
Problem with select query that includes a date
I've been fighting with this for about 4 hours - yes, quite literally... I've never been good with date stuff. I have a brain block.
Anyway, here's the situation:
I have an Access database that has a time/date field. There are no times, just a date in mm/dd/yyyy format.
That table is a list of classes held for the past three years. I want to make a query that only shows the classes that have ended after January 1 of this year. I don't want to put 01/01/2010 in the query itself because I want it to still work next year.
This is the current query:
<cfquery name="classes" datasource="#DSN#" dbtype="ODBC">
SELECT classesTitles.ClassTitle, classesTitles.ClassDesc, classCatagories.catagoryName, classes.classStart, classes.classEnd, classes.classNotes, owners.fName, owners.lName, classTime.timeSlot, classes.classID, classes.classLimit
FROM classCatagories INNER JOIN (((classes INNER JOIN classesTitles ON classes.classTitle = classesTitles.classTitleID) INNER JOIN classTime ON classes.classTime = classTime.timeID) INNER JOIN owners ON classes.classInstructor = owners.ownerID) ON classCatagories.catagoryID = classesTitles.ClassType
WHERE classes.classEnd < 01/01/#DatePart("yyyy", now())#
ORDER BY classes.classStart, classCatagories.catagoryName, classTime.timeSlot, classesTitles.ClassTitle
</cfquery>
I don't get any results, but I should get a list of every class that has an end date before January 1 of this year - about 200 records.
When I swap around the where clause to:
<cfquery name="classes" datasource="#DSN#" dbtype="ODBC">
SELECT classesTitles.ClassTitle, classesTitles.ClassDesc, classCatagories.catagoryName, classes.classStart, classes.classEnd, classes.classNotes, owners.fName, owners.lName, classTime.timeSlot, classes.classID, classes.classLimit
FROM classCatagories INNER JOIN (((classes INNER JOIN classesTitles ON classes.classTitle = classesTitles.classTitleID) INNER JOIN classTime ON classes.classTime = classTime.timeID) INNER JOIN owners ON classes.classInstructor = owners.ownerID) ON classCatagories.catagoryID = classesTitles.ClassType
WHERE classes.classEnd > 01/01/#DatePart("yyyy", now())#
ORDER BY classes.classStart, classCatagories.catagoryName, classTime.timeSlot, classesTitles.ClassTitle
</cfquery>
I get EVERY class in the database, and I should only be getting about 50
The classes are about 8 weeks long, the begin date and end date are in the database as date/time fields, so I need to show everything that ended in 2010, regardless of when it started.
I'm sure it's something glaringly obvious, but it's escaping me.
THANKS
MichelleThe format of your date field in access is irrelevent to the situation at hand. Use proper date objects instead of trying to build a suitable string. For the first of January of the current year, the coldfusion functions createdate(), year(), and now() are your freinds. Then, in case Adam's post was not clear, use cfqueryparam with the resulting variable.
Maybe you are looking for
-
Windows 7 VM has DNS Problem When Using Wireless
Hello All, I've been fighting this virtual machine networking problem for over a week now. If anyone has a well-informed suggestion (not a guess) I would appreciate hearing about it. Here's the problem in a nutshell and then I'll give more details: I
-
Missing Component in Dreamweaver Trial Install?
I was hoping someone could shed some light on an issue I am having with a Dreamweaver trial I am evaluating. I downloaded and installed CS4 trial the other day with no issues. Then my computer crashed and windows automatically did a restore. When
-
Installation of grid control on windows xp
can any body provide me compelete guide installing 10g grid R1 on xp,linux and management agents on winows and linux operating systems. Thanks in Advance
-
I do not have Toshiba laptop but it came with the Toshiba Bluetooth Stack (XP SP2). My cell phone requires the Microsoft Bluetooth stack in order to use internet sharing and PAN. I uninstalled the Toshiba Bluetooth stack and have the MS stack install
-
Naming the parameters of a callable statement
Hi! I am having some kind of a problem here. I am currently working on a software with a database.OK, simple. The problem is that we have different kind of databases (oracle, Sybase, DB2) AND different schema! We are obviously trying to keep the pers