Write statement Query
Hi Guys,
I have a internal table with data like below.
PALNO TKNUM
0000001144-01-1 /5 |0000001144|
0000001144-01-1 /5 |0000001144|
0000001144-01-1 /5 |0000001144|
0000001144-01-1 /5 |0000001144|
0000001144-01-2 /5 |0000001144
0000001144-01-2 /5 |0000001144|
0000001144-01-3 /5 |0000001144|
I want to use write statement for displaying these values seperatly to identity palet(PALNO) wise..
when palno is same I want write statement to display as follows
PALNO TKNUM
0000001144-01-1 /5 |0000001144|
0000001144-01-1 /5 |0000001144|
0000001144-01-1 /5 |0000001144| For same PALNO
0000001144-01-1 /5 |0000001144|
SKIP 2 Lines.
PALNO TKNUM
0000001144-01-2 /5 |0000001144| For same PALNO
0000001144-01-2 /5 |0000001144|
SKIP 2 Lines
PALNO TKNUM
0000001144-01-3 /5 |0000001144| For same PALNO
If this possible by write statements.
Plz let me know.
Thanks,
Prasad.
Data:w_tknum like itab-tknum.
Loop at itab.
If w_tknum ne Itab-knum and sy-tabix > 1.
Skip 2.
Endif.
w_tknum ne Itab-knum.
Endloop.
Regards,
Gurpreet
Similar Messages
-
How to write named query if we want to use IN syntax in our sql statement?
I cannot find a suitable category about named query, so please move to appropriate place if there is any.
When we write named query, below statement is fine.
Query q2 = em.createQuery("SELECT o FROM Table1 as o WHERE field1 = :input1"); q2.setParameter("input1", "value1");
Now, my question is, how can I write this type of query when we want to use the IN sql syntax? As below statement CANNOT return correct results. Even I tried to put a pair of single quote [ ':input2' ], it won't help also.
Query q2 = em.createQuery("SELECT o FROM Table1 as o WHERE field2 IN (:input2)"); q2.setParameter("input1", "3633, 3644");
Can anyone suggest? Thanks.roamer wrote:
Now, my question is, how can I write this type of query when we want to use the IN sql syntax? As below statement CANNOT return correct results. Even I tried to put a pair of single quote [ ':input2' ], it won't help also.
Query q2 = em.createQuery("SELECT o FROM Table1 as o WHERE field2 IN (:input2)");
q2.setParameter("input1", "3633, 3644");
Can anyone suggest?The above is in your code right? Not in some configuration file?
Then you do it the same way as with regular jdbc/sql.
1. You start with a collection of values - call it collection A.
1. Create a for loop that dynamically creates the string using 'bind' variables (whatever you want to call the 'colon' entity in the above).
2. Call the createQuery method using the string that was created
3. Create a second loop that iterates over A and populates with setParameter.
Pseudo code
Object[] A = ...
String sql = "SELECT o FROM Table1 as o WHERE field2 IN (";
for (int i=1; i <= A.length; i++)
if (i == 1)
sql += ":input" + i;
else
sql += ",:input" + i;
sql += ")";
Query q2 = em.createQuery(sql);
for (int i=1; i <= A.length; i++
q2.setParameter("input" + i, A[i-1]);
}By the way there is a jdbc forum. -
Issue with WRITE statement from Internal Table
Hi All,
I have written the below code in a infoset query, the syntax check is ok & when i run the query in debugging mode, i find the internal table being filled with the values & the write statement outputing the values as well.
But the problem is when i execute the query the output does not show all the lines, instead just displays the last record . What could be the mistake?
Is it because i have defined Y_EBELN, Y_EBELP & Y_OPENQTY as nodes in the Extras Tab of the infoset & have chosen this for display in my query? How to display the output from my internal table in my query output?
Hope my problem is clear, await clarification.
Vivek
Code
types:
Begin of itab,
wl_ebeln type eket-ebeln,
wl_ebelp type eket-ebelp,
wl_openqty type eket-menge,
End of itab.
Data: il_po type table of itab with header line.
*Display open PO for materials
SELECT EKETEBELN EKETEBELP EKETMENGE EKETWEMNG EKET~EINDT
INTO (Y_EBELN, Y_EBELP, WL_MENGE, WL_WEMNG, Y_EINDT)
FROM EKET
INNER JOIN EKPO
ON EKETEBELN = EKPOEBELN
AND EKETEBELP = EKPOEBELP
INNER JOIN MARD
ON EKPOMATNR = MARDMATNR
AND EKPOWERKS = MARDWERKS
AND EKPOLGORT = MARDLGORT
WHERE EKPO~MATNR = MARD-MATNR
AND EKPO~WERKS = MARD-WERKS
AND EKPO~LGORT = MARD-LGORT
AND EKPO~LOEKZ = SPACE
AND EKPO~ELIKZ = SPACE.
*Display only still open qty per schedule line
Y_OPENQTY = WL_MENGE - WL_WEMNG.
il_po-wl_ebeln = Y_EBELN.
il_po-wl_ebelp = Y_EBELP.
il_po-wl_openqty = Y_OPENQTY.
append il_po.
ENDSELECT.
ENDIF.
Loop at il_po.
write:/ il_po-wl_ebeln, il_po-wl_ebelp, il_po-wl_openqty.
endloop.Hi Vivek,
Try it like this.
Data: Begin of itab,
lifnr type lfa1-lifnr,
name1 type lfa1-name1,
land1 type lfa1-land1,
End of itab,
it_lfa1 like table of itab with header line,
lifnr like lfa1-lifnr,
name1 like lfa1-name1,
land1 like lfa1-land1.
select lifnr name1 land1 into (lifnr, name1, land1)
from lfa1.
it_lfa1-lifnr = lifnr.
it_lfa1-name1 = name1.
it_lfa1-land1 = land1.
append it_lfa1.
endselect.
loop at it_lfa1.
write:/ it_lfa1-lifnr, it_lfa1-name1, it_lfa1-land1.
endloop.
Note:
In place of the above select you insert your join select statement. It is working for me.
You have declared your internal table wrongly. In the internal table instead of TYPE use LIKE, it will work.
Hope this will work for you.
Thanks & Regards
Haritha. -
How to write select query for this
Hi,
I had a html form and in the for i had drop down box and it needs to select multiple values from the drop down box. When i select multiple values then i have to write the SQL select statement query .
When i try to write the select statement and trying to run i am getting error.
select * from Table
where emo_no = '1,2,3'
this is how i write query please suggest me how to write query for selecting multiple values from the drop down box.
Thanksselect * from Table
where emo_no in ( 1,2,3)
for integer values
select * from Table
where emo_no in ('1','2','3')
for characters
If we talk about large scale applications that may have millions of records, I would suggest this.
declare @t table (v int)
insert into t (v) values (1)
insert into t (v) valves (2)
insert into t (v) values (3)
select *
from table
inner join @t t on table.emo_no = t.v
Using "in" for a where clause is not so bad for filtering on a few values, but if you are filtering a lot of rows and a lot of values (emo_no) the performance degrades quickly for some reasons beyond the scope of this.
This is just one solution, I'll through this out as well, instead of an in memory (@t) table, doing a disk based temp table (#t) and creating an index on the column "v".
create table #t (v int)
insert into #t (v) values (1)
insert into #t (v) valves (2)
insert into #t (v) values (3)
create index ix_t on #t (v)
select *
from table
inner join #t t on table.emo_no = t.v
drop table #t
Pardon any syntax errors and careful using a drop statement.
Sometimes in memory tables work better than disk temp tables, it takes some testing and trial and error depending on your datasets to determine the best solution.
Probably too much info ;-)
Byron Mann
[email protected]
[email protected]
Software Architect
hosting.com | hostmysite.com
http://www.hostmysite.com/?utm_source=bb -
I need a help to write the query
Id
Child
Parent
Is Sub Parent
Is Parent
1
chld1
y
2
chld2
chld1
y
3
chld3
chld1
y
4
chld4
chld1
5
chld5
chld2
y
6
chld6
chld2
7
chld7
chld5
8
chld8
Q: please check the above table, id no 1-7 are linked with parent and id no 8 is independent child, i need to write a query to display the below result based on the below scenarios
Scenario 1: if user passes the child 1 the result should be as showed below table all 7 rows need to show.
Scenario 2: if user passes the child in between child 1 - child 7 then also the result should be as showed below table all 7 rows.
RESULT
Id
Child
Parent
1
chld1
2
chld2
chld1
3
chld3
chld1
4
chld4
chld1
5
chld5
chld2
6
chld6
chld2
7
chld7
chld5
Thanks in advanceHi,
next time please post sample data as CREATE TABLE and INSERT statements or with clause like this:
with mychildren as
select 1 id, 'chld1' chld, null prnt, null is_sub_parent, 'Y' is_parent from dual union all
select 2 id, 'chld2' chld, 'chld1' prnt, 'Y' is_sub_parent, null is_parent from dual union all
select 3 id, 'chld3' chld, 'chld1' prnt, 'Y' is_sub_parent, null is_parent from dual union all
select 4 id, 'chld4' chld, 'chld1' prnt, null is_sub_parent, null is_parent from dual union all
select 5 id, 'chld5' chld, 'chld2' prnt,'Y' is_sub_parent, null is_parent from dual union all
select 6 id, 'chld6' chld, 'chld2' prnt, null is_sub_parent, null is_parent from dual union all
select 7 id, 'chld7' chld, 'chld5' prnt, null is_sub_parent, null is_parent from dual union all
select 8 id, 'chld8' chld, null prnt, null is_sub_parent, null is_parent from dual
Here a couple of test with chld7 and chld1
with mychildren as
select 1 id, 'chld1' chld, null prnt, null is_sub_parent, 'Y' is_parent from dual union all
select 2 id, 'chld2' chld, 'chld1' prnt, 'Y' is_sub_parent, null is_parent from dual union all
select 3 id, 'chld3' chld, 'chld1' prnt, 'Y' is_sub_parent, null is_parent from dual union all
select 4 id, 'chld4' chld, 'chld1' prnt, null is_sub_parent, null is_parent from dual union all
select 5 id, 'chld5' chld, 'chld2' prnt,'Y' is_sub_parent, null is_parent from dual union all
select 6 id, 'chld6' chld, 'chld2' prnt, null is_sub_parent, null is_parent from dual union all
select 7 id, 'chld7' chld, 'chld5' prnt, null is_sub_parent, null is_parent from dual union all
select 8 id, 'chld8' chld, null prnt, null is_sub_parent, null is_parent from dual
, find_root as
select chld
from mychildren
where prnt is null
start with chld='chld1' --- this is your input
connect by prior prnt=chld
select id, chld, prnt
from mychildren
start with chld=(select chld from find_root)
connect by prior chld=prnt
ID CHLD PRNT
1 chld1
2 chld2 chld1
5 chld5 chld2
7 chld7 chld5
6 chld6 chld2
3 chld3 chld1
4 chld4 chld1
Changing it to chld7 does not change the output.
Output is now sorted according hierarchical query. If you need a different sort order you can specify what you want.
Regards.
Al -
CAn we write a query like this
CAn we write a query like this?
If not how can this be changed?
select col1,col2,col3.col4
from table 1
where col1,col2 in(select col1,col2 from table2)Or it may be identical:
SQL> CREATE TABLE t1 (c INT NOT NULL);
Table created.
SQL> CREATE TABLE t2 (c INT NOT NULL);
Table created.
SQL> INSERT ALL
2 INTO t1 VALUES (rn)
3 INTO t2 VALUES (rn)
4 SELECT rownum AS rn FROM user_tables WHERE rownum <= 15;
30 rows created.
SQL> BEGIN
2 DBMS_STATS.GATHER_TABLE_STATS(user,'T1');
3 DBMS_STATS.GATHER_TABLE_STATS(user,'T2');
4 END;
5 /
PL/SQL procedure successfully completed.
SQL> SELECT * FROM t1
2 WHERE EXISTS
3 ( SELECT 1 FROM t2 WHERE c = t1.c )
4
SQL> @xplan
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 15 | 90 | 5 |
|* 1 | HASH JOIN SEMI | | 15 | 90 | 5 |
| 2 | TABLE ACCESS FULL | T1 | 15 | 45 | 2 |
| 3 | TABLE ACCESS FULL | T2 | 15 | 45 | 2 |
Predicate Information (identified by operation id):
1 - access("T2"."C"="T1"."C")
SQL> SELECT * FROM t1
2 WHERE c IN
3 ( SELECT c FROM t2 )
4
SQL> @xplan
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 15 | 90 | 5 |
|* 1 | HASH JOIN SEMI | | 15 | 90 | 5 |
| 2 | TABLE ACCESS FULL | T1 | 15 | 45 | 2 |
| 3 | TABLE ACCESS FULL | T2 | 15 | 45 | 2 |
Predicate Information (identified by operation id):
1 - access("T1"."C"="T2"."C") -
Write a query for which has its field name as input parameter
Hi All,
I need to write a query for SSRS report. StartDate, EndDate and ChangedField are the input parameters.
Let's consider that we are taking employee details. The table contains lot of fields like emp name,add1,add2,city,state,country,designation,rank etc. We have almost 30 fields are there. These field name are coming as input parameter "ChangedField"
. I need to show the records which belong to the start date and end date also data change for the field which is given in the input parameter "ChangedField". That meand If I give ChangedField="city", we need to check for data which
has been updated with new City name in the given time period.
Please suggest.
Regards,
JulieHi Julie,
Per my understanding that you have many fields in the table to be displayed in the report, some of the fields will always show and others should be hide and show based on the selection of the parameters which include the columns names, right?
By default, we can't display columns dynamically in the report automatically without insert this column in the report before. So, in your scenario, I will suggest you to add all the columns in the reports first and then add show/hide expression on
the column visibility based on the selection of the parameter "ChangedField", when some of the fields selectted they will be display, otherwise they will be hidden. For the fields which you want to be always displayed will not need to add the expression
in the column visibility.
Details steps about how to acheive this, please referencet to the article below:
Displaying Dynamic Columns in SSRS Report
If you still have any problem, please feel free to ask.
Regards,
Vicky Liu
Vicky Liu
TechNet Community Support -
WRITE STATEMENT IS GETTING EXECUTED BUT NOT GETTING DISPLAYED
HII All,
i hv created a selection screen with push button. Now when i m clicking that pushbutton, output is not getting displayed..when i debug program ,control enters in switch case and also executes write statement but write statement is not getting displayed.. below is the code ..
SELECTION-SCREEN BEGIN OF BLOCK INPUT WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN PUSHBUTTON 10(20) TEXT-002 USER-COMMAND FIR.
SELECTION-SCREEN PUSHBUTTON 35(20) TEXT-003 USER-COMMAND SECOND.
SELECTION-SCREEN END OF BLOCK INPUT.
WA-EMP_NO = 123.
WA-EMP_CO = 'A'.
WA-EMP_N = 'APOORV'.
APPEND WA TO IT_TAB.
AT SELECTION-SCREEN.
CASE SY-UCOMM.
WHEN 'FIR'.
PERFORM SUB1.
WHEN 'SECOND'.
APPEND LINES OF IT_TAB FROM 2 TO 3 TO IT_TAB1.
WRITE:/ 'SECOND INTERNAL TABLE CONTENTS'.
LOOP AT IT_TAB1 INTO WA1.
WRITE:/15 SY-TABIX, WA1-EMP_NO NO-ZERO, WA1-EMP_CO, WA1-EMP_N.
ENDLOOP.
ENDCASE.
FORM SUB1.
LOOP AT IT_TAB INTO WA.
WRITE:/ SY-TABIX, WA-EMP_NO NO-ZERO, WA-EMP_CO, WA-EMP_N.
ENDLOOP.
ENDFORM.
Plz help me..
Edited by: Julius Bussche on Jan 29, 2009 1:40 PM
Code tags added and please dont use Caps-Lock.HI,
SELECTION-SCREEN BEGIN OF BLOCK INPUT WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN PUSHBUTTON 10(20) TEXT-002 USER-COMMAND FIR.
SELECTION-SCREEN PUSHBUTTON 35(20) TEXT-003 USER-COMMAND SECOND.
SELECTION-SCREEN END OF BLOCK INPUT.
WA-EMP_NO = 123.
WA-EMP_CO = 'A'.
WA-EMP_N = 'APOORV'.
APPEND WA TO IT_TAB.
* AT SELECTION-SCREEN. "Comment this
START-OF_SELECTION. " Add this
CASE SY-UCOMM.
WHEN 'FIR'.
PERFORM SUB1.
WHEN 'SECOND'.
APPEND LINES OF IT_TAB FROM 2 TO 3 TO IT_TAB1.
WRITE:/ 'SECOND INTERNAL TABLE CONTENTS'.
LOOP AT IT_TAB1 INTO WA1.
WRITE:/15 SY-TABIX, WA1-EMP_NO NO-ZERO, WA1-EMP_CO, WA1-EMP_N.
ENDLOOP.
ENDCASE.
FORM SUB1.
LOOP AT IT_TAB INTO WA.
WRITE:/ SY-TABIX, WA-EMP_NO NO-ZERO, WA-EMP_CO, WA-EMP_N.
ENDLOOP.
ENDFORM. -
Write Statements are not getting Displayed
Hi All,
We are going for Upgrade from 4.7 to ECC. So, in my program we have few write statements which are not getting displayed in the output. Those write statments are seen as errors in the extended check as Char. strings w/o text elements will not be translated: 'Income Tax Worksheet'.
Could any one please help me to over come this errors and Display the wite statements.
Thanks
ShashikanthHave you mapped the checked and unchecked glyphs to be used?
Check the doc and blog for check boxes.
Regards
tim -
A better way to write last_day query
Hi folks,
I am looking for a better way to write a query to find last_day in month but if its sunday or holiday it should move to day before last day.
So for example if 31 is sunday it should go for 30, if 30 is holiday it should move down to 29.
I got this so far but the connect by level is hardcoded to 15. Want to see if there is a better way to get this working:
select max(datum)
from ( select last_day(trunc(sysdate)) - level + 1 as datum
from dual
connect by level < 15)
where to_char(datum, 'day') != 'sunday'
and to_char(datum, 'DDMM') not in
('3012')Best regards,
IgorLike this
select to_char(last_day_month, 'Day') day_is,
last_day_month,
last_day_month - case when to_char(last_day_month, 'fmday') = 'sunday' then 1
when to_char(last_day_month, 'ddmm' ) = '3012' then 1
else 0
end last_business_day_month
from (
select last_day(add_months(trunc(sysdate, 'year'), level-1)) last_day_month
from dual
connect by level <= 12
DAY_IS LAST_DAY_MONTH LAST_BUSINESS_DAY_MONTH
Tuesday 31-JAN-12 31-JAN-12
Wednesday 29-FEB-12 29-FEB-12
Saturday 31-MAR-12 31-MAR-12
Monday 30-APR-12 30-APR-12
Thursday 31-MAY-12 31-MAY-12
Saturday 30-JUN-12 30-JUN-12
Tuesday 31-JUL-12 31-JUL-12
Friday 31-AUG-12 31-AUG-12
Sunday 30-SEP-12 29-SEP-12
Wednesday 31-OCT-12 31-OCT-12
Friday 30-NOV-12 30-NOV-12
Monday 31-DEC-12 31-DEC-12 -
Double click on output in write statement
hi,
i have a list of PO as outout thru write statement(classical).i wamt to open me23n with the double click on that particular po.
how could i do this? answer with full code.Hello
After capture the number of the PO do the following
SET PARAMETER ID 'BES' FIELD <n° of the PO>
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
Hope it helps
Kleber Santos -
Print write stat at end of all pages in report
Hi,
I want to print write stat at end of all pages in report.
Thanks,
Ashahi ,
u can use End-of-Page event to print write statement at ever end of the page.
for Ex:
Report ztest line-count 8(3).
start-of selection.
loop at itab...
write:/ .........
endloop.
end-of-page.
write:/ "end of page'.
revert back if any issues.
reward with points if helpful.
regards,
naveen. -
How to show a data in Higher fonts with write statement
Hi.
how to show a data in Higher fonts with write statement
I want to show a statement in large fonts with write statement.How can I do that.
write : 'Company Address'.
Regards
MaveMave,
I would precribe you to use the FORMAT options available with the WRITE Statement.
Because this allows us to differentitate between the HEADIngs and the LINEs in the report.
Here u go dear:
http://help.sap.com/saphelp_47x200/helpdata/en/9f/db9e7135c111d1829f0000e829fbfe/frameset.htm
Thanks
Kam -
Crystal Report XI: Can you write your query in SQL instead of using the GUI
Hello
In crystal report version XI, can you write your query in sqlplus and then use the crystal report designer to build your report instead of using the GUI . I would like to be able to go database and show sql query and open that query and make changes directly there, is that possible on this version, if yes is there a setting somewhere? Please let me know.
Thank you
alphaMoved to Database forum.
No you can no longer modify the SQL directly. Use a Command Object to enter the SQL directly.
Thank you
Don -
Need to use ALV instead of write:/ statement in this perform
How can I use ALV within this perform instead of using Write:/ in it.
Scroll the program. At the bottom there is use of write:/ statement.
How to use ALV in this perform?
FORM display_logfile .
TYPES: BEGIN OF lt_openbal,
bukrs TYPE bukrs,
hkont TYPE hkont,
augdt TYPE augdt,
augbl TYPE augbl,
zuonr TYPE dzuonr,
gjahr TYPE gjahr,
belnr TYPE belnr_d,
buzei TYPE buzei,
shkzg TYPE shkzg,
dmbtr TYPE dmbtr,
END OF lt_openbal,
BEGIN OF lt_log2,
hkont TYPE hkont,
opbal TYPE dmbtr,
exp TYPE dmbtr,
cap TYPE dmbtr,
err TYPE dmbtr,
END OF lt_log2,
BEGIN OF lt_zsct_record,
kongr TYPE ckml_kongr,
hkont TYPE hkont,
zcptp TYPE zdecptp,
zerrc TYPE zdeerrc,
END OF lt_zsct_record.
DATA: lw_zscs_record TYPE t_zscs_record,
lw_zsct_record TYPE lt_zsct_record,
li_zsct_record TYPE STANDARD TABLE OF lt_zsct_record,
li_zsct_record1 TYPE STANDARD TABLE OF lt_zsct_record,
lw_log1 TYPE t_zscs_record,
li_log1 TYPE STANDARD TABLE OF t_zscs_record,
li_temp TYPE STANDARD TABLE OF t_zsct_autoinv,
li_openbal TYPE STANDARD TABLE OF lt_openbal,
li_openbal_mod TYPE STANDARD TABLE OF lt_openbal,
li_log2 TYPE STANDARD TABLE OF lt_log2,
li_log2_t TYPE STANDARD TABLE OF lt_log2,
lw_log2 TYPE lt_log2,
lw_log2_t TYPE lt_log2,
lw_openbal_mod TYPE lt_openbal,
lw_openbal TYPE lt_openbal.
i_zscs_record1 = i_zscs_record.
DELETE i_zscs_record1 WHERE zerrf NE space.
SORT i_error_bapi BY recid.
SORT i_error_bdc BY recid.
SORT i_suc_bdc BY recid.
SORT i_suc_bapi BY recid.
SORT i_zscs_record1 BY recid.
LOOP AT i_zscs_record1 INTO lw_zscs_record.
lw_log1-recid = lw_zscs_record-recid.
lw_log1-kongr = lw_zscs_record-kongr.
lw_log1-hkont = lw_zscs_record-hkont.
CALL FUNCTION 'CONVERSION_EXIT_ABPSP_OUTPUT'
EXPORTING
input = lw_zscs_record-projk
IMPORTING
output = lw_log1-projk.
lw_log1-werks = lw_zscs_record-werks.
lw_log1-matnr = lw_zscs_record-matnr.
lw_log1-zcptp = lw_zscs_record-zcptp.
lw_log1-zerrf = lw_zscs_record-zerrf.
To Check if the KONGR value is is equal to 'E'
IF lw_zscs_record-kongr = c_e.
READ TABLE i_error_bapi INTO w_error_bapi WITH KEY recid = lw_zscs_record-recid BINARY SEARCH.
IF sy-subrc = 0.
lw_log1-zerrc = w_error_bapi-number.
lw_log1-zertx = w_error_bapi-message.
ENDIF.
ELSE.
READ TABLE i_error_bdc INTO w_error_bdc WITH KEY recid = lw_zscs_record-recid BINARY SEARCH.
IF sy-subrc = 0.
lw_log1-zerrc = w_error_bdc-number.
lw_log1-zertx = w_error_bdc-message.
ENDIF.
ENDIF.
*****To Check if the KONGR value is is equal to 'E'
IF lw_zscs_record-kongr = c_e.
READ TABLE i_suc_bapi INTO w_suc_bapi WITH KEY recid = lw_zscs_record-recid BINARY SEARCH.
IF sy-subrc = 0.
lw_log1-zerrf = c_x.
*******To check if lw_log1-zertx = w_error_bapi-message.
ENDIF.
ELSE.
READ TABLE i_suc_bdc INTO w_suc_bdc WITH KEY recid = lw_zscs_record-recid BINARY SEARCH.
IF sy-subrc = 0.
lw_log1-zerrf = c_x.
********To check if lw_log1-zertx = w_error_bdc-message.
ENDIF.
ENDIF.
APPEND lw_log1 TO li_log1.
*To clear work areas
CLEAR: lw_log1,
w_error_bapi,
w_suc_bdc,
w_suc_bapi,
w_error_bdc,
lw_zscs_record.
ENDLOOP.
IF NOT i_zscs_record1 IS INITIAL.
*To retrieve required data from the custom table ZSCT_AUTOINV
SELECT saknr
fipos
geber
saknr_off
fipos_off
FROM zsct_autoinv
INTO TABLE i_autoinv
FOR ALL ENTRIES IN i_zscs_record1
WHERE saknr = i_zscs_record1-hkont.
IF sy-subrc = 0.
SORT i_autoinv.
ENDIF.
ENDIF.
Assigning I_AUTOINV data into a local internal table for further processing
li_temp[] = i_autoinv[ ].
Sort LI_TEMP by SAKNR
SORT li_temp BY saknr.
Delete adjacent duplicates from LI_TEMP comparing SAKNR
DELETE ADJACENT DUPLICATES FROM li_temp COMPARING saknr.
Check if LI_TEMP is initial
IF NOT li_temp[] IS INITIAL.
Retrieve required data from table BSIS for all the G/L accounts
SELECT bukrs
hkont
augdt
augbl
zuonr
gjahr
belnr
buzei
shkzg
dmbtr
FROM bsis
INTO TABLE li_openbal_mod
FOR ALL ENTRIES IN li_temp
WHERE bukrs = c_wfp
AND hkont = li_temp-saknr.
IF sy-subrc = 0.
ENDIF.
ENDIF.
SORT li_openbal_mod BY hkont.
****Retrieve data from table ZSCT_RECORD for further processing for
****all entries where ZERRF is equal to space
IF p_prsall = c_x.
SELECT kongr
hkont
zcptp
zerrc
FROM zsct_record "#EC CI_NOFIRST
INTO TABLE li_zsct_record
WHERE zerrf = space.
IF sy-subrc = 0.
*****Delete records from LI_ZSCT_RECORD where HKONT value is equal to space
DELETE li_zsct_record WHERE hkont EQ space.
ENDIF.
ELSEIF p_cstcpt = c_x.
SELECT kongr
hkont
zcptp
zerrc
FROM zsct_record "#EC CI_NOFIRST
INTO TABLE li_zsct_record
WHERE zerrf = space
AND kongr NE c_e.
IF sy-subrc = 0.
******Delete records from LI_ZSCT_RECORD where HKONT value is equal to space
DELETE li_zsct_record WHERE hkont EQ space.
ENDIF.
ELSEIF p_cstexp = c_x.
SELECT kongr
hkont
zcptp
zerrc
FROM zsct_record "#EC CI_NOFIRST
INTO TABLE li_zsct_record
WHERE zerrf = space
AND kongr EQ c_e.
IF sy-subrc = 0.
******Delete records from LI_ZSCT_RECORD where HKONT value is equal to space
DELETE li_zsct_record WHERE hkont EQ space.
ENDIF.
ENDIF.
LOOP AT li_openbal_mod INTO lw_openbal.
IF lw_openbal-shkzg = c_shkzg1.
v_todmbtr = v_todmbtr + lw_openbal-dmbtr.
ELSEIF lw_openbal-shkzg = c_shkzg2.
v_todmbtr = v_todmbtr - lw_openbal-dmbtr.
ENDIF.
AT END OF hkont.
lw_log2-hkont = lw_openbal-hkont. "GL account
lw_log2-opbal = ABS( v_todmbtr ). "Open item balance
APPEND lw_log2 TO li_log2.
*log record appended with GL Account and account open item balance
CLEAR: v_todmbtr,
lw_openbal.
ENDAT .
ENDLOOP.
SORT li_log2 BY hkont.
LOOP AT li_log2 INTO lw_log2.
CLEAR v_totexppe.
CLEAR v_totcapit.
CLEAR v_toterror.
*Cost portion to be capitalised calculated
LOOP AT li_zsct_record INTO lw_zsct_record
WHERE hkont = lw_log2-hkont AND
kongr NE c_e AND zerrc IS INITIAL.
v_totcapit = v_totcapit + lw_zsct_record-zcptp. "CC calculated
ENDLOOP.
*Expensed cost portion calculated
LOOP AT li_zsct_record INTO lw_zsct_record WHERE
hkont = lw_log2-hkont AND
kongr = c_e AND zerrc IS INITIAL .
v_totexppe = v_totexppe + lw_zsct_record-zcptp. "ECP calculated
ENDLOOP.
*Errors calculated
LOOP AT li_zsct_record INTO lw_zsct_record WHERE
hkont = lw_log2-hkont AND
zerrc IS NOT INITIAL .
v_toterror = v_toterror + lw_zsct_record-zcptp. "Errors calculated
ENDLOOP.
lw_log2-exp = v_totexppe. "Expensed cost portion
lw_log2-cap = v_totcapit. "Cost capitalised
lw_log2-err = v_toterror. "Errors
*Cost portion capitalised expensed and errors in calculation are
*trans ported for related GL accont
MODIFY li_log2 FROM lw_log2
TRANSPORTING exp cap err.
ENDLOOP.
LOOP AT li_log2_t INTO lw_log2_t.
MODIFY li_log2 FROM lw_log2_t TRANSPORTING opbal WHERE hkont = lw_log2_t-hkont.
CLEAR : lw_log2_t.
ENDLOOP.
WRITE:/1(15) text-018,sy-datum. "SESSION DATE:
SKIP 2.
For printing the hear level of the output log
WRITE:/1(16) text-003, "Record ID number
20(11) text-004, "Reason Code
34(10) text-005, "GL Account
47(12) text-006, "Project Code
62(5) text-007, "Plant
70(9) text-008, "Commodity
82(25) text-009, "Cost portion To be posted
110(12) text-010, "Success Flag
125(10) text-011, "Error Code
138(50) text-012. "Error TXT
SKIP.
LOOP AT li_log1 INTO lw_log1.
WRITE:/1(16) lw_log1-recid,
20(11) lw_log1-kongr,
34(10) lw_log1-hkont,
47(12) lw_log1-projk,
62(5) lw_log1-werks,
70(9) lw_log1-matnr,
82(25) lw_log1-zcptp, "#EC UOM_IN_MES
110(12) lw_log1-zerrf,
125(10) lw_log1-zerrc,
138(80) lw_log1-zertx.
CLEAR:lw_log1.
ENDLOOP.
SKIP 2.
IF NOT li_log2 IS INITIAL.
ULINE.
WRITE:/1(16) text-013, "GL ACCOUNT CODE
20(17) text-014, "OPEN ITEM BALANCE
40(21) text-015, "EXPENSED COST PORTION
64(24) text-016, "CAPITALIZED COST PORTION
92(20) text-017. "ERRORS.
LOOP AT li_log2 INTO lw_log2.
WRITE:/1(16) lw_log2-hkont,
20(17) lw_log2-opbal,
40(21) lw_log2-exp,
64(24) lw_log2-cap,
92(20) lw_log2-err.
CLEAR:lw_log2.
ENDLOOP.
ENDIF.
ENDFORM. " DISPLAY_LOGFILEhi,
You need to use FM 'REUSE_ALV_LIST_DISPLAY' for this purpose. For using this FM, you need to create a field catlog which will contain all information about the coloumns you want to display for example their position, their text etc.
Below there is a small demo for achiving this.
TYPE-POOLS:slis.
DATA : i_fieldcat TYPE slis_t_fieldcat_alv.
TYPES: BEGIN OF ty_itab1,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
werks LIKE vbap-werks,
lgort LIKE vbap-lgort,
END OF ty_itab1.
DATA: itab1 TYPE TABLE OF ty_itab1.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
SELECT-OPTIONS: s_vbeln FOR vbak-vbeln.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
PERFORM select_data.
END-OF-SELECTION.
PERFORM display.
FORM select_data .
SELECT vbeln
posnr
werks
lgort
INTO CORRESPONDING FIELDS OF TABLE itab1
FROM vbap
WHERE vbeln IN s_vbeln.
IF sy-subrc <> 0.
MESSAGE 'Enter The Valid Sales Document Number'(t04) TYPE 'I'.
EXIT.
ENDIF.
ENDFORM.
IF alv_list = 'X'.
PERFORM build_fieldcat TABLES i_fieldcat[]
USING :
*-Output-field Table Len Ref fld Ref tab Heading Col_pos
'VBELN' 'ITAB1' 10 'VBAP' 'VBELN' '' 1,
'POSNR' 'ITAB1' 6 'VBAP' 'POSNR' '' 2,
'WERKS' 'ITAB1' 4 'VBAP' 'WERKS' '' 3,
'LGORT' 'ITAB1' 4 'VBAP' 'LGORT' '' 4.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = c_pf_status
i_callback_user_command = 'USER_COMMAND '
it_events = t_alv_events[]
it_fieldcat = i_fieldcat[]
TABLES
t_outtab = itab1[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
FORM build_fieldcat TABLES fpt_fieldcat TYPE slis_t_fieldcat_alv
USING fp_field TYPE slis_fieldname
fp_table TYPE slis_tabname
fp_length TYPE dd03p-outputlen
fp_ref_tab TYPE dd03p-tabname
fp_ref_fld TYPE dd03p-fieldname
fp_seltext TYPE dd03p-scrtext_l
fp_col_pos TYPE sy-cucol.
*-- Local data declaration
DATA: wl_fieldcat TYPE slis_fieldcat_alv.
*-- Clear WorkArea
wl_fieldcat-fieldname = fp_field.
wl_fieldcat-tabname = fp_table.
wl_fieldcat-outputlen = fp_length.
wl_fieldcat-ref_tabname = fp_ref_tab.
wl_fieldcat-ref_fieldname = fp_ref_fld.
wl_fieldcat-seltext_l = fp_seltext.
wl_fieldcat-col_pos = fp_col_pos.
*-- Update Field Catalog Table
APPEND wl_fieldcat TO fpt_fieldcat.
ENDFORM.
Maybe you are looking for
-
How do you get your password when the recovery email is no longer your email account?
I can not remember my apple I'd password and the email address that I used to have no longer exists so they send the information there and I can't get it. When I answer the security question it doesn't correspond although I am pretty sure I know my b
-
Gurus, how does FCP resolve odd geometry? If I have an odd sized clip and I Insert Paste into a standard fixed-sized Timeline, does FCP force the clip to fit into that size? Here was my dilemma with some video from a television newsroom (and you can
-
Screening, Search, and Detection Mission Areas: Prevention, Protection Description: Identify, discover, or locate threats and/or hazards through active and passive surveillance and search procedures. This may include the use of systematic exam
-
My stocks app is not saving changes no matter what changes I make. After making a change, I'll exit the app, re-enter and it defaults back to a whole bunch of stuff I didn't add. Can someone help me with this, I'm not sure where to even start!
-
How to recover keychain generated password in a website?
While registering for a website, keychain offered me a passcode and I accepted that. Now the website won't let keychain autofill and I don't know the passcode. Since my account in that website is not yet activated, there is no forgot password option.