Dynamic write statements
HI Experts,
Can anybody tell me following answers.
I have
select-options: p_date like Ztab1-date. (we can choose here till 15dates)
low =01/07/07 to high-15/07/07
output screen.
<b>items date1 date2 date3 date4 date5 date6 date7 date8 date9 ..date15 TotalQty</b>
<b>cat1</b> 1000 500 -
700 700 2900
<b>cate2</b> so on
<b>cate3</b>
In write statement: i want my program to decide total qty column should write just select-options range. like if i given in select options 17/07/07 to 18/07/07. my total column should come after next to 2columns, when i given 7 days its shud just next to 7th column,when i given 01st jul 07 to 15th july 07, total come just next to 15th column.
How to do that? Pls sugest.
Thanks in advance.
You can use field-symbols:
field-symbols: <fvalue>.
Loop at itab.
New-line.
DO .
ASSIGN COMPONENT sy-index OF STRUCTURE itab TO <fvalue> .
IF sy-subrc NE 0 .
EXIT .
ENDIF .
write <fvalue>.
ENDDO.
Endloop.
You will have to add the headings first and the row labels if needed.
Please reward points if helpful.
Minami
Similar Messages
-
Help With SUBSTR in dynamic SQL statement
Following is the dynamic SQL statement.
EXECUTE IMMEDIATE 'UPDATE table_name pml
SET pml.'|| con_fields.field ||' = SUBSTR(pml.'||con_fields.field||' ||'' ''||
(SELECT pml1.'||con_fields.field||'
FROM table_name pml1
WHERE pml1.grp_id = '||los_concats.grp_id ||'
AND pml1.row_id = '||los_concats.row_id||'
AND pml1.loser_flg = ''Y''),1, '||con_fields.max_length||')
WHERE pml.grp_id = '||los_concats.grp_id ||'
AND pml.loser_flg IS NULL ';
what it does is that it updates a particular field. This field is concatenated by a field of a similar record.
My problem is with SUBSTR function. Since I am concatenating fields I do not want the field to be updated greater than max_length on that field, the reason why I use SUBSTR. the select query inside SUBSTR works alright with one of the AND condition in a WHERE clause not present. When I add that additional condition it gives me this error.
ORA-00907: missing right parenthesis.
Is there any way to get around this problem. Does SQL has other than SUBSTR function which can limit the character length.
Appreciate it.The other alternative I thought about was to do this first
EXECUTE IMMEDIATE 'SELECT pml.'||con_fields.field||'
FROM table_name pml
WHERE pml.grp_id = '||los_concats.grp_id||'
AND pml.row_id = '||los_concats.row_id||'
AND pml.loser_flg = ''Y''
' INTO v_concat_field;
write into the variable v_concat_field and then use it into the previous script.
But on this I get SQL Command not properly terminated, I don't get it Why?
Donald I tried with your suggested script. It works fine with one of the conditions eliminated. I don't understand what the error trying to say?
Thanks -
CX_SY_DYNAMIC_OSQL_SEMANTICS error with dynamic SELECT statement
Hello Gurus,
We have a dynamic SELECT statement in our BW Update Rules where the the Selection Fields are populated at run-time and so are the look-up target and also the WHERE clause. The code basically looks like below:
SELECT (lt_select_flds)
FROM (lf_tab_name)
INTO CORRESPONDING FIELDS OF TABLE <lt_data_tab>
FOR ALL ENTRIES IN <lt_source_data>
WHERE (lf_where).
In this instance, we are selecting 5 fields from Customer Master Data and the WHERE condition for this instance of the run is as below:
WHERE: DIVISION = <lt_source_data>-DIVISION AND DISTR_CHAN = <lt_source_data>-DISTR_CHAN AND SALESORG = <lt_source_data>-SALESORG AND CUST_SALES = <lt_source_data>-SOLD_TO AND OBJVERS = 'A'
This code was working fine till we were in BW 3.5 and is causing issues after we moved to BW 7.31 recently. Ever since, when we execute our data load, we get the CX_SY_DYNAMIC_OSQL_SEMANTICS. THE ERROR TEXT SAYS 'Unable to interpret '<LT_SOURCE_data>-DOC_NUMBER'.
Can you pleasesuggest what can we do to this code to get is working correctly ? What has changed in ABAP Objects that has been introduced from BI 7.0 that could be causing this issue?
Would appreciate any help we can get here.
Thanks
ArvindHi,
Please try this.
data: lv_where type string.
concatenate 'vbeln' 'in' 'r_vbeln' into lv_where separated by space.
select *from table into itab where (lv_where).
Also please check this sample code.
REPORT ZDYNAMIC_WHERE .
TABLES: VBAK.
DATA: CONDITION TYPE STRING.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
END OF ITAB.
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
CONCATENATE 'VBELN' 'IN' 'S_VBELN.'
INTO CONDITION SEPARATED BY SPACE.
SELECT VBELN POSNR FROM VBAP INTO TABLE ITAB
WHERE (CONDITION).
LOOP AT ITAB.
WRITE 'hello'.
ENDLOOP.
Regards,
Ferry Lianto -
Dear all,
I want to know how to code a write statement with dynamic positioning like below:
Data: V_POS type i.
V_POS = 10.
Write:/V_POS 'Testing'.
I'm getting syntax error for the above. Please comment.The following is the information from SAP Help.
You can position the output of a WRITE statement on the list by making a format specification before the field name as follows:
Syntax
WRITE AT [/][<pos>][(<len>)] <f>.
where
the slash '/' denotes a new line,
<pos> is a number or variable up to three digits long denoting the position on the screen,
<len> is a number or variable up to three digits long denoting the output length.
If the format specification contains only direct values (that is, no variables), you can omit the keyword AT.
WRITE 'First line.'.
WRITE 'Still first line.'
WRITE / 'Second line.'
WRITE /13 'Third line.'
For more info, see link:
[http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9e3035c111d1829f0000e829fbfe/content.htm]
Regards,
Lakshmi. -
How can I open a cursor for dynamic sql statement
Hi,
I'm facing issues opening a cursor for dynamic sql statement : PLS-00455: cursor 'RESULT1' cannot be used in dynamic SQL OPEN statement.
CREATE OR REPLACE FUNCTION DEMO
(MN_I in VARCHAR)
return AB_OWNER.ABC_Type.NonCurTyp is
RESULT1 AB_OWNER.ABC_Type.NonCurTyp;
sql_stmt VARCHAR2(4000);
BEGIN
sql_stmt := 'SELECT * FROM AB_OWNER.DUN WHERE JZ_I in ('||mn_i||') ORDER BY app.ACC_I';
OPEN RESULT1 FOR sql_stmt;
END IF;
return RESULT1;
END DEMO;
What changes should I make in the code so that it doesn't fail? I can't change the definition of RESULT1 cursor though.Gangadhar Reddy wrote:
I used SYS REFCURSOR and was able to implement successfully.How many times did you run this successful implementation that does not use bind variables?
Because this is what will happen when it runs a lot.
http://download.oracle.com/docs/cd/E11882_01/server.112/e17766/e2100.htm#sthref1874
http://forums.oracle.com/forums/search.jspa?q=%2BORA-04031%20%2Bbind&objID=c84&dateRange=all&rankBy=10001&start=30
And you will have to regularly restart the server, or possibly slightly less invasive, flush the shared pool.
Flushing Shared Pool regularly
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1516005546092
>
Ok, this is an easy one to diagnose.
You are not using bind variables. This is terrible. Flushing the shared pool is a bad
solution -- you are literally killing the performance on your box by not using them.
If I was to write a book on how to build non scalable applications in Oracle, this
would be the first and last chapter. This is a major cause of performance issues and a
major inhibitor of scalability in Oracle. The way the Oracle shared pool (a very
important shared memory data structure) operates is predicated on developers using bind
variables. If you want to make Oracle run slowly, even grind to a total halt just
refuse to use them.
>
But, please feel free to go ahead with this successful implementation.
I just hope anyone else who reads this doesn't make the same mistake. -
Dynamic IF statement in PL/SQL on-insert trigger in Forms 6.0
I would like to build a dynamic IF statement for the on-insert trigger in a form... Users are restricted to which "projects" they are allowed to enter into the database. These restrictions are based on a security table. The same restrictions are used to build the dynamic where clause that limits which previously inserted records the users can see when they are in the form. Since the restrictions are identical, I want to use the same logic that I use to build a where clause to build a dynamic If statement instead... If the statement is true, the user can insert the record. If its false, they can't.
I'm trying to this as follows:
declare
big_if varchar2(10000) :=' ';
begin
if :global.admin='YES'
then
insert_record;
else
declare
cursor cur1 is
select paren1, field, comparison_operator, value, paren2, and_or
from rcdb.user_project_assign2
where user_id = user;
c1_rec cur1%ROWTYPE;
begin
for c1_rec in cur1 loop
big_if:= big_if | | c1_rec.paren1 | | ':tbl_main_data.' | |c1_rec.field | |c1_rec.comparison_operator | | '''' | | c1_rec.value | | '''' | | c1_rec.paren2 | | ' '| | c1_rec.and_or | | ' ';
end loop;
end;
if big_if
then
insert_record;
else message('You are not allowed to insert this record');
end if;
end if;
end;
The problem is in the line
IF big_if
big_if is the variable that holds the text to my if statement (hense dynamic If statement) but I can't get the code to allow me to use that variable.
Can anyone do this?
nullThat code was great, but forms isn't allowing me to use the dbms_sql so I have to make a procedure out of forms and call it from the form. Both my form code and the procedure are compiling, but I"m still getting an error when the result is coming back to the form...
the code in the form is:
declare
big_if varchar2(10000) :=' ';
result varchar2(5) :=' ';
check_state varchar2(2):=:tbl_main_data.state_abr;
check_region varchar2(3):=:tbl_main_data.region_abr;
check_program varchar2(25):=:tbl_main_data.program;
begin
if :global.admin='YES'
then
insert_record;
else
declare
cursor cur1 is
select paren1, field, comparison_operator, value, paren2, and_or
from rcdb.user_project_assign2
where user_id = user;
c1_rec cur1%ROWTYPE;
begin
for c1_rec in cur1 loop
big_if:= big_if | | c1_rec.paren1;
if c1_rec.field = 'state_abr' then
big_if:=big_if | | 'check_state' | |c1_rec.comparison_operator | | '''' | | c1_rec.value | | '''' | | c1_rec.paren2 | | ' '| | c1_rec.and_or | | ' ';
elsif c1_rec.field = 'region_abr' then
big_if:=big_if | | 'check_region' | |c1_rec.comparison_operator | | '''' | | c1_rec.value | | '''' | | c1_rec.paren2 | | ' '| | c1_rec.and_or | | ' ';
elsif c1_rec.field = 'program' then
big_if:=big_if | | 'check_program' | |c1_rec.comparison_operator | | '''' | | c1_rec.value | | '''' | | c1_rec.paren2 | | ' '| | c1_rec.and_or | | ' ';
end if;
end loop;
end;
message(big_if); pause;
message(check_state); pause;
message(check_region); pause;
message(check_program); pause;
rcdb.check_if(big_if,result,check_state,check_region,check_program);
message('resulte = | |result| |');
if result = 'TRUE' then insert_record;
else
message ('you cant enter');
end if;
end if;
end;
AND THE CODE IN THE PROCEDURE IS....
create or replace procedure check_if (
big_if in varchar2,
result out varchar2,
check_state in varchar2,
check_region in varchar2,
check_program in varchar2
IS
v_indx binary_integer := 0;
v_sql_syntax varchar2(32767);
root_cursor number;
ignore integer;
your_if_statement VARCHAR2(32767);
v_check VARCHAR2(5);
BEGIN
your_if_statement := ' if '| |big_if| |' then :v_check := ''TRUE''; end if;';
v_sql_syntax := 'begin '| |your_if_statement| |' end;';
root_cursor := dbms_sql.open_cursor;
v_sql_syntax := replace(replace(REPLACE(v_sql_syntax,chr(10),' '),chr(13),' '),chr(9),' ');
dbms_sql.parse(root_cursor,v_sql_syntax,dbms_sql.v7);
dbms_sql.bind_variable( root_cursor, ':v_check',v_check,5);
ignore := dbms_sql.execute(root_cursor);
dbms_sql.variable_value(root_cursor, ':v_check', v_check);
if v_check = 'TRUE' then result:='TRUE';
else
result:='FALSE';
end if;
dbms_sql.close_cursor(root_cursor);
END check_if;
DO YOU KNOW WHATS WRONG? -
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 -
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. -
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 -
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. -
ABAP "WRITE" Statements for Debugging
Just curious to know if one can use ABAP write statements in Update Rules for debugging and auditing, and where the results are actually written to, and if they're accessible via the AWB.
Thank you.Jerry you can write to the monitor from within the update rules.
The debug message you were going to write out instead go ahead and append your message to the monitor structure.
FORM compute_data_field
TABLES <b>MONITOR</b> STRUCTURE RSMONITOR
USING COMM_STRUCTURE LIKE /BIC/CS8ZTESTODS
RECORD_NO LIKE SY-TABIX
RECORD_ALL LIKE SY-TABIX
SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS
CHANGING RESULT LIKE /BIC/VZTESTCUBT-INVCD_QTY
RETURNCODE LIKE SY-SUBRC
ABORT LIKE SY-SUBRC.
You will then be able to view any messages you have added to the monitor in the monitor.
Hope this helps.
Cheers -
Doubt in write statement at the time of using Unicode
Hi ,
here we are working in unicode ,we are facing one problem in write statement
whenever we activate the code we are getting the problem like ,"Literals that take up more than one line not permitted", but this report is working good in 4.7 but while executing in ecc6.0 ,we are facing the problem like this ,so how to solve this please let me know.
Thanks in advance,
sai krishna.It is a warning message & can be ignored.. but if you want to avoid the synatx error, you have to concateante the string ie..
old code:
data w_str type string.
w_str = 'abdcdcsdcsdcsdcdcdc
dscsdcsdcsdcsd'.
write: / w_str.
new code.
data w_str type string.
concatenate 'abdcdcsdcsdcsdcdcdc'
' dscsdcsdcsdcsd' into w_trs.
write:/ w_str.
~Suresh
Maybe you are looking for
-
I had a problem with my List Cube Transaction and for that reason, I had a look at the Infoprovider and also the Data Sources. When tried to execute the infoproviders in LISTCUBE, the following messages are being displayed in BWT system: 1. Error rea
-
Question: TLD and custom Tag Usage.
Hi, I am new to the custom tags and I am confused with one of the examples. The TLD has <tag> <name>item</name> <tagclass>com.taglib.wdjsp.mut.OutlineItemTag</tagclass> <bodycontent>JSP</bodycontent>
-
Clearing UCS Manager fault about unused adapter uplink from C-series
I have a number of C240M3 servers in a UCS infrastructure. They all have two VIC 1225 adapters and when they were initially connected, the technicians accidentally connected the second adapter on some of them to the FEXs. For now at least, we only
-
IPhoto wont import my images?
Hello, I plugged in my iPhone to my MacBook Pro today and I wanted to import all my pictures from my iPhone to my computer. I opened iPhoto and clicked import all... and It gave me an error message saying "iPhoto cannot import your photos because the
-
The Repackaging of Oracle Hyperion Applications.
Hi, Windows 7 packaging team has brought up an issue with some of our desktop packages. They have mentioned the source that we used to build packages in XP uses a bundled version of JRE 1.6x and as it turns out, there are serious security issues with