Going to a transaction from a write statement
Hi,
I have a simple write statement which gives a PO number and a description about it. When i click on the PO number, it should directly go to transaction ME22N. Please note that i know how to implement the same requirement from the output ALV grid. But now iam not knowing how to go to the transaction from a output write statement. Please suggest what can be done ?
Hi ..
Check this..
AT LINE-SELECTION.
READ LINE sy-lilli FIELD VALUE itab-po_num. "PO field
IF itab-po_num NE SPACE.
CALL FUNCTION 'ME_DISPLAY_PURCHASE_DOCUMENT'
EXPORTING
i_ebeln = itab-po_num
i_enjoy = 'X'
i_edit = 'X'
* i_etenr =
EXCEPTIONS
not_found = 1
no_authority = 2
invalid_call = 3
preview_not_possible = 4
OTHERS = 5.
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.
"PS: with enjoy transaction like ME22n it works perfect
Message was edited by:
Perez C
Similar Messages
-
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. -
Print with write statements from webynpro does not trigger top-of-page
Print launched from webdynpro application via application server created with write statements does not trigger top-of-page event. When print is done from sapgui it works ok. The idea is to reuse backend print which was created for sapgui with abap list made application log in webdynpro application.
Hi,
here a short extract like i do it:
CLASS LCL_EVENT_HANDLER DEFINITION .
PUBLIC SECTION .
METHODS:
HANDLE_PRINT_TOP_OF_PAGE
FOR EVENT PRINT_TOP_OF_PAGE OF CL_GUI_ALV_GRID,
ENDCLASS. "LCL_EVENT_HANDLER DEFINITION
* Event-Händer Implementierung
CLASS LCL_EVENT_HANDLER IMPLEMENTATION .
METHOD HANDLE_PRINT_TOP_OF_PAGE.
PERFORM PRINT_TOP_OF_PAGE.
ENDMETHOD.
ENDCLASS.
CREATE OBJECT GR_EVENT_HANDLER.
SET HANDLER
GR_EVENT_HANDLER->HANDLE_PRINT_TOP_OF_PAGE FOR GR_ALVGRID_LEFT.
CALL METHOD GR_ALVGRID_LEFT->SET_TABLE_FOR_FIRST_DISPLAY
FORM PRINT_TOP_OF_PAGE.
LINSZ = SY-LINSZ - 16.
WRITE: / 'Report: ', SY-REPID,
AT LINSZ 'Datum:', SY-DATUM.
WRITE: / 'Benutzer: ', SY-UNAME,
AT LINSZ 'Zeit: ', SY-UZEIT.
ENDFORM.
hope it helps.
Regards, Dieter -
Retrieve WRITE statements of a called report from a caller one: howto?
Hi experts, need an help for a (imho) quite interesting task. I have a little report that works on a single purchase order and , at the end of the execution, prints on screen a simple message using a WRITE statement. (something like "PO number X processed with/without errors", and eventually other lines showing a specific error).
Now, I'm just creating a "caller" report that gets po numbers from an input file, and process them one by one; a really simple task, but considering I'd like not to modify the original "called" program, I'm wondering about how to get messages in order to print them on screen at the end of the loop.
I tried something as follows (note: it_orders is an internal table containing my po numbers):
LOOP AT it_orders.
CLEAR listobject. "TYPE TABLE OF ABAPLIST
SUBMIT MY_CALLED_REPORT
WITH num_ctr = it_orders-ebeln
WITH flag = flag
EXPORTING LIST TO MEMORY AND RETURN.
* read from memory
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
LISTOBJECT = LISTOBJECT
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
LOOP AT LISTOBJECT INTO wa_list.
APPEND wa_list TO FINALLIST.
ENDLOOP.
ENDLOOP.
FORMAT INTENSIFIED COLOR = 1. "heading
WRITE: 'RESULTS'.
SKIP.
* write to output
CALL FUNCTION 'WRITE_LIST'
* EXPORTING
* WRITE_ONLY = 'X'
TABLES
LISTOBJECT = FINALLIST
EXCEPTIONS
EMPTY_LIST = 1
OTHERS = 2.
But... it doesn't work. The above code only shows the message of the first order processed, but I can't understand why. Can somebody give a "clean" way to solve this issue? It would be helpful in many cases similar to the one I'm working on
Thanks in advanceThanks *DP, it almost worked for me. There's a little problem anyway; the first row in the output screen is the one of the last call of the REPORT called by a submit. To show it clearly, here's an example: suppose I've got 4 purchase orders to process, stored in an itab 'po_table': 300000001, 300000002, 300000003 and 300000004.
Then the output of the trace is the following:
Cancellazione totale dal DB
PO 3000001145 processed correctly.
10.03.2009
PO 3000001143 processed correctly.
10.03.2009
PO 3000001144 processed correctly.
10.03.2009
PO 3000001145 processed correctly.
10.03.2009
As you can see, the original output of the last call of the 'inner' report is visible on top. How can I suppress the output of the called program in order to avoid this replication? Thanks in advance.
Nvrmind, my fault. Works correctly now, thanks
Edited by: Matteo Montalto on Mar 10, 2009 10:01 AM -
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 -
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 -
How to use Write statement along with ALV output
Hi expert,
currently i have a requirement where i am first displaying message with write statement and after that ALV should be displayed ...something like below:
vendor number is wrong.
material number is wrong.
plant is wrong.
and then here ALV output -list of records updated in the database.
but as of now the ALV is shown first and when going back then the write message information is dispayed.
can anyone help how we can get this in only one screen?
Thanks!!!
RajeshMay below example give you some idea.
TYPE-POOLS: slis.
DATA: BEGIN OF it_kna1 OCCURS 0,
kunnr TYPE kna1-kunnr,
name1 TYPE kna1-name1,
ort01 TYPE kna1-ort01,
END OF it_kna1.
DATA: it_fcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
START-OF-SELECTION.
SELECT kunnr name1 ort01
FROM kna1 INTO TABLE it_kna1 UP TO 10 ROWS.
END-OF-SELECTION.
WRITE:/ 'Write Statement Display' HOTSPOT ON.
AT LINE-SELECTION.
CLEAR it_fcat.
it_fcat-fieldname = 'KUNNR'.
it_fcat-tabname = 'IT_KNA1'.
it_fcat-seltext_l = 'Customer'.
APPEND it_fcat.
CLEAR it_fcat.
it_fcat-fieldname = 'NAME1'.
it_fcat-tabname = 'IT_KNA1'.
it_fcat-seltext_l = 'Customer Name'.
APPEND it_fcat.
CLEAR it_fcat.
it_fcat-fieldname = 'ORT01'.
it_fcat-tabname = 'IT_KNA1'.
it_fcat-seltext_l = 'City'.
APPEND it_fcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = it_fcat[]
TABLES
t_outtab = it_kna1[]. -
Help me to control the transactions from jsp to java bean
Please anyone can guide me how to control the transactions from jsp to java bean. I am using the Websphere studio 5.1 to develop the database application. I would like to know two method to handle the database. First, I would like to know how I can control the transactions from jsp by using java bean which is auto generated for SQL statement to connect to the database. Following code are jsp and java bean.....
// call java bean from jsp
for (i=0;i<10;i++)
addCourse.execute(yr,sem,stdid,course,sec);
I write this loop in jsp to call java bean..
here is java bean for AddCourse.java
package com.abac.preregist.courseoperation;
import java.sql.*;
import com.ibm.db.beans.*;
* This class sets the DBModify property values. It also provides
* methods that execute your SQL statement and return
* a DBModify reference.
* Generated: Sep 7, 2005 3:10:24 PM
public class AddCourse {
private DBModify modify;
* Constructor for a DBModify class.
public AddCourse() {
super();
initializer();
* Creates a DBModify instance and initializes its properties.
protected void initializer() {
modify = new DBModify();
try {
modify.setDataSourceName("jdbc/ABAC/PreRegist/PRERMIS");
modify.setCommand(
"INSERT INTO informix.javacourseouttemp " +
"( yr, sem, studentid, courseid, section ) " +
"VALUES ( :yr, :sem, :studentid, :courseid, :section )");
DBParameterMetaData parmMetaData = modify.getParameterMetaData();
parmMetaData.setParameter(
1,
"yr",
java.sql.DatabaseMetaData.procedureColumnIn,
java.sql.Types.SMALLINT,
Short.class);
parmMetaData.setParameter(
2,
"sem",
java.sql.DatabaseMetaData.procedureColumnIn,
java.sql.Types.SMALLINT,
Short.class);
parmMetaData.setParameter(
3,
"studentid",
java.sql.DatabaseMetaData.procedureColumnIn,
java.sql.Types.CHAR,
String.class);
parmMetaData.setParameter(
4,
"courseid",
java.sql.DatabaseMetaData.procedureColumnIn,
java.sql.Types.CHAR,
String.class);
parmMetaData.setParameter(
5,
"section",
java.sql.DatabaseMetaData.procedureColumnIn,
java.sql.Types.SMALLINT,
Short.class);
} catch (SQLException ex) {
ex.printStackTrace();
* Executes the SQL statement.
public void execute(
String userid,
String password,
Short yr,
Short sem,
String studentid,
String courseid,
Short section)
throws SQLException {
try {
modify.setUsername(userid);
modify.setPassword(password);
modify.setParameter("yr", yr);
modify.setParameter("sem", sem);
modify.setParameter("studentid", studentid);
modify.setParameter("courseid", courseid);
modify.setParameter("section", section);
modify.execute();
// Free resources of modify object.
finally {
modify.close();
public void execute(
Short yr,
Short sem,
String studentid,
String courseid,
Short section)
throws SQLException {
try {
//modify.setUsername(userid);
//modify.setPassword(password);
modify.setParameter("yr", yr);
modify.setParameter("sem", sem);
modify.setParameter("studentid", studentid);
modify.setParameter("courseid", courseid);
modify.setParameter("section", section);
modify.execute();
// Free resources of modify object.
finally {
modify.close();
* Returns a DBModify reference.
public DBModify getDBModify() {
return modify;
I would like to know that how can I do for autocommit from jsp. For example, the looping is 10 times which mean I will add 10 records to the db. If the last record is failed to add to db, "how can I rollback the perivious records?" or guide me to set the commit function to handle that case. Thanks a lot for take your time to read my question.Hello.
The best method is using a session bean and container managed transactions. Other method is using sessions bean and the user transaction object (JTA-JTS).
so, JDBC has transaction management too.
good luck. -
Not able to see write statements in spool
Hi,
When i'm executing a bdc program using call transaction in background i'm not able to see the write statements in the spool.Please let me know if there is anything which should be done to send the write statements to spool.
thanks in advance,
poornimaHi poornima
The best way to do is store it in memory once your BDC is done use FMs to do the writing process .
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = l_abap
EXCEPTIONS
NOT_FOUND = 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.
CALL FUNCTION 'LIST_TO_ASCI'
EXPORTING
LIST_INDEX = -1
WITH_LINE_BREAK = ' '
IMPORTING
LIST_STRING_ASCII =
TABLES
listasci = ascitab
listobject = l_abap
EXCEPTIONS
EMPTY_LIST = 1
LIST_INDEX_INVALID = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Writing Messages
LOOP AT ascitab FROM 6.
WRITE: ascitab-line.
ENDLOOP.
Regards
Hitesh -
I want to change screenshot location from my Solid State hard drive with OSX on it, to my 2nd storage hard drive, how do I do this?
I am aware of "defaults write com.apple.screencapture *location*" but I want to change the location to my 2nd drive which doesn't have OSX on it... everytime I've tried to insert MacintoshHD2 in there it just doesn't work... any tips?I'm having the same problem. I've entered the following path in terminal:
"defaults write.com.apple.screencapture location /Volumes/Macintosh HD 2/[my username]/Downloads"
But it's not working. It keeps going to the SSD Downloads folder.
What am I doing 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. -
We just moved from the United States to Costa Rica. The first two days my mac worked great. Then all of a sudden I was trying to use a game application and the screen went black and there is a white cursor which I can move around, but I can't escape it. When I restart it seems okay and I see my main screen, but only for a second and then it goes black again.
This computer was brand new in June. Is it the humidity??? What can I do. Please help!!!!No guarantess but try smc and pram resets,
-
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 -
Calling a jsp page from an if statement??
Hi I am going toexplain what I can do already first then explain what I want to do:
1) I have an html page that has a form. This form requests a userId and password to be entered. Upon submission of this form a java servlet is called
2) the java servlet checks the initial inputted values of the form. I check to enusre that the user did enter somthing in both fields. I also check to make sure that the user did not enter just spaces.
3) I return a error message to the user if the input is invalid ( I do this through a series of if statements)
What I want to happen: Instead of simply return an error message, I would like to jump out of the java if statement and into a jsp page (or another html form I havent decided yet)
In this seperate page I would like to display the form again with the incorrect areas highlighted. I am just not sure how to transfer control from the if statement to the new jsp page.
All help is appreciated!
ThanksIf you want to transfer control from servlet(.java file) to JSP file or servlet to servlet than use
public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException
if(..)
res.sendRedirect("http://abc.com/foldername/page1.html");
}else if(..){
res.sendRedirect("http://abc.com/foldername/page2.jsp");
}else if(..){
res.sendRedirect("servlet3");
}//end if
}//end doPost -
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
-
My iMac won't recognize my external hard drive connected by FireWire 400
I have an external hard drive connected to my Intel-based iMac through a FireWire 400 cable. The drive doesn't come up on the desktop after turning on the hard drive power. If I connect through the USB cable, it appears quickly on the desktop. Why is
-
Cannot open Microsoft Office 2004
Hi. I have MS Office 2004 installed on my iMac, for using Excel and Word. All of a sudden this morning, I could not print an Excel file, due to some sort of error. Don't know what it was. I then found that I could not open any Office application. I g
-
How to create a my own control
Suppose I want to create my control, how can I do it. Like TextField with Button, i have to create a control by some methods. How to do it.
-
Milestone Error when changing the status of service request.
Hi Expert. I got an issue where service request is displayed with an error "Item 10: Start and end dates must be identical for a milestone date". I took around 200 service requests and observed that in the change history, the response profile of the
-
Programmat​ically modify scan engine scaling
I need to be able to programmatically adjust the scaling factors for my cRIO analog channel. I manage all my I/O from an external spreadsheet that gets compiled and ftp'd to 9 cRIO targets. Each cRIO will have different scaling factors. I understa