Internal table in sap script
Hello All ,
I have got a internal table with tracking numbers and I want to print all the numbers in that internal table on sap script.
Please advise.
Thanks
Moderator message: please search for available information before asking.
locked by: Thomas Zloch on Sep 13, 2010 1:09 PM
Hi,
You can create a sub-routine and pass all the table entries in variables and then you can print them.
Similar Messages
-
Want to display multiple rows of internal table on sap script
hi friends,
i have created element in window.and in report i have called all functions as open_form,start_form,write_form,end_form,close_form.
enclosing write_form function in 'loop at itab' and 'endloop',,,,gives error start_form missing even it is written before loop at sattement...
and if start_form is also included in loop at and endloop statement then it shows per record per page......
please suggest .....how to make all records on same page 1 after another rather than of different pagesHi
See the sample script program and code accordingly
*& Report ZTEST12121
*& SAPScripts Example 1
REPORT ztest12121.
*DATABASE TABLES
TABLES: ekko,ekpo,lfa1.
*INTERNAL TABLES AND STRUCTURES
DATA i_ekko LIKE ekko.
DATA i_ekpo LIKE ekpo OCCURS 0 WITH HEADER LINE.
DATA i_lfa1 LIKE lfa1.
*PARAMETERS
PARAMETERS: p_ebeln LIKE ekko-ebeln.
*VARIABLES
DATA MAT TYPE STRING VALUE 'MAT NO'.
DATA iTe TYPE STRING VALUE 'ITEM NO'.
DATA QTY TYPE STRING VALUE 'QTY'.
DATA UOM TYPE STRING VALUE 'UOM'.
DATA NET TYPE STRING VALUE 'NET PRICE'.
Data var type integer value 0.
*DATABASE SELECTS
*Header data
SELECT SINGLE * FROM ekko INTO i_ekko WHERE ekko~ebeln = p_ebeln.
IF sy-subrc = 0.
*Item Data
SELECT * FROM ekpo INTO TABLE i_ekpo WHERE ekpo~ebeln = p_ebeln.
IF sy-subrc NE 0.
WRITE 'PURCHASE DOCUMENT ITEM DATA ERROR'.
ELSE.
*Vendor Details
SELECT SINGLE * FROM lfa1 INTO i_lfa1 WHERE lfa1~lifnr = i_ekko-lifnr.
IF sy-subrc NE 0.
WRITE 'VENDOR DOCUMENT ITEM DATA ERROR'.
ENDIF.
ENDIF.
ELSE.
WRITE 'THIS PURCHASE DOCUMENT NUMBER DOESNOT EXISTS'.
ENDIF.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
APPLICATION = 'TX'
ARCHIVE_INDEX =
ARCHIVE_PARAMS =
DEVICE = 'PRINTER'
DIALOG = 'X'
form = 'ZSCRIPT_1'
language = sy-langu
OPTIONS =
MAIL_SENDER =
MAIL_RECIPIENT =
MAIL_APPL_OBJECT =
RAW_DATA_INTERFACE = '*'
SPONUMIV =
IMPORTING
LANGUAGE =
NEW_ARCHIVE_PARAMS =
RESULT =
EXCEPTIONS
CANCELED = 1
DEVICE = 2
FORM = 3
OPTIONS = 4
UNCLOSED = 5
MAIL_OPTIONS = 6
ARCHIVE_ERROR = 7
INVALID_FAX_NUMBER = 8
MORE_PARAMS_NEEDED_IN_BATCH = 9
SPOOL_ERROR = 10
CODEPAGE = 11
OTHERS = 12
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 'WRITE_FORM'
EXPORTING
ELEMENT = 'OFFICEAD'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'OFFICEAD'
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 'WRITE_FORM'
EXPORTING
ELEMENT = 'PODET'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'PODET'
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 'WRITE_FORM'
EXPORTING
ELEMENT = 'TOP'
FUNCTION = 'SET'
TYPE = 'TOP'
WINDOW = 'MAIN'
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT I_EKPO.
var = i_ekpo-netpr * i_ekpo-menge.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'BODY'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT =
RDI_RESULT =
TABLES
OTFDATA =
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SEND_ERROR = 3
SPOOL_ERROR = 4
CODEPAGE = 5
OTHERS = 6
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
<b>Reward points for useful Answers</b>
Regards
Anji -
How to Send Internal table to SAP Spool using Function Modules or Methods?
Hi Experts,
How to Send Internal table to SAP Spool using Function Modules or Methods?
Thanks ,
KiranThis is my code.
I still get the no ABAP list data for the spool, even tho I can see it sp01?
REPORT Z_MAIL_PAYSLIP.
* Declaration Part *
tables: PERNR, PV000, T549Q, V_T514D, HRPY_RGDIR.
infotypes: 0000, 0001, 0105, 0655.
data: begin of ITAB occurs 0,
MTEXT(25) type C,
PERNR like PA0001-PERNR,
ABKRS like PA0001-ABKRS,
ENAME like PA0001-ENAME,
USRID_LONG like PA0105-USRID_LONG,
end of ITAB.
data: W_BEGDA like HRPY_RGDIR-FPBEG,
W_ENDDA like HRPY_RGDIR-FPEND.
data: RETURN like BAPIRETURN1 occurs 0 with header line.
data: P_INFO like PC407,
P_FORM like PC408 occurs 0 with header line.
data: P_IDX type I,
MY_MONTH type T549Q-PABRP,
STR_MY_MONTH(2) type C,
MY_YEAR type T549Q-PABRJ,
STR_MY_YEAR(4) type C,
CRLF(2) type x value '0D0A'.
data: W_CMONTH(10) type C.
data: TAB_LINES type I,
ATT_TYPE like SOODK-OBJTP.
data: begin of P_INDEX occurs 0,
INDEX type I,
end of P_INDEX.
constants: begin of F__LTYPE, "type of line
CMD like PC408-LTYPE value '/:', "command
TXT like PC408-LTYPE value 's', "textline
end of F__LTYPE.
constants: begin of F__CMD, "commands
NEWPAGE like PC408-LINDA value '',
end of F__CMD.
data: P_LIST like ABAPLIST occurs 1 with header line.
*data: OBJBIN like SOLISTI1 occurs 10 with header line,
data: OBJBIN like LVC_S_1022 occurs 10 with header line,
DOCDATA like SODOCCHGI1,
OBJTXT like SOLISTI1 occurs 10 with header line,
OBJPACK like SOPCKLSTI1 occurs 1 with header line,
RECLIST like SOMLRECI1 occurs 1 with header line,
OBJHEAD like SOLISTI1 occurs 1 with header line,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_buffer type string,
l_no_of_bytes TYPE i,
l_pdf_spoolid LIKE tsp01-rqident,
l_jobname LIKE tbtcjob-jobname.
data: file_length type int4,
spool_id type rspoid,
line_cnt type i.
*-------------------------------------------------------------------* * INITIALIZATION *
OBJBIN = ' | '.
append OBJBIN.
OBJPACK-HEAD_START = 1.
data: S_ABKRS like PV000-ABKRS.
data: S_PABRP like T549Q-PABRP.
data: S_PABRJ like T549Q-PABRJ.
* SELECTION SCREEN *
selection-screen begin of block BL1.
parameters: PAY_VAR like BAPI7004-PAYSLIP_VARIANT default 'ESS_PAYSLIPS' obligatory.
selection-screen end of block BL1.
START-OF-SELECTION.
s_ABKRS = PNPXABKR.
S_PABRP = PNPPABRP.
s_pabrj = PNPPABRJ.
w_begda = PN-BEGDA.
w_endda = PN-ENDDA.
get pernr.
* "Check active employees
rp-provide-from-last p0000 space pn-begda pn-endda.
CHECK P0000-STAT2 IN PNPSTAT2.
* "Check Payslip Mail flag
rp-provide-from-last p0655 space pn-begda pn-endda.
CHECK P0655-ESSONLY = 'X'.
rp-provide-from-last p0001 space pn-begda pn-endda.
* "Find email address
RP-PROVIDE-FROM-LAST P0105 '0030' PN-BEGDA PN-ENDDA.
if p0105-usrid_LONG ne ''.
ITAB-PERNR = P0001-PERNR.
ITAB-ABKRS = P0001-ABKRS.
ITAB-ENAME = P0001-ENAME.
ITAB-USRID_LONG = P0105-USRID_LONG.
append itab.
clear itab.
endif.
"SY-UCOMM ='ONLI'
END-OF-SELECTION.
*------------------------------------------------------------------* start-of-selection.
write : / 'Payroll Area : ', S_ABKRS.
write : / 'Payroll Period/Year : ',STR_MY_MONTH,'-',STR_MY_YEAR. write : / 'System Date : ', SY-DATUM.
write : / 'System Time : ', SY-UZEIT.
write : / 'User Name : ', SY-UNAME.
write : / SY-ULINE.
sort ITAB by PERNR.
loop at ITAB.
clear : P_INFO, P_FORM, P_INDEX, P_LIST, OBJBIN, DOCDATA, OBJTXT, OBJPACK, RECLIST, TAB_LINES.
refresh : P_FORM, P_INDEX, P_LIST, OBJBIN, OBJTXT, OBJPACK, RECLIST.
* Retrieve Payroll results sequence number for this run
select single * from HRPY_RGDIR where PERNR eq ITAB-PERNR
and FPBEG ge W_BEGDA
and FPEND le W_ENDDA
and SRTZA eq 'A'.
* Produce payslip for those payroll results
if SY-SUBRC = 0.
call function 'GET_PAYSLIP'
EXPORTING
EMPLOYEE_NUMBER = ITAB-PERNR
SEQUENCE_NUMBER = HRPY_RGDIR-SEQNR
PAYSLIP_VARIANT = PAY_VAR
IMPORTING
RETURN = RETURN
P_INFO = P_INFO
TABLES
P_FORM = P_FORM.
check RETURN is initial.
* remove linetype from generated payslip
loop at p_form.
objbin = p_form-linda.
append objbin.
line_cnt = line_cnt + 1.
endloop.
file_length = line_cnt * 1022.
* create spool file of paylsip
CALL FUNCTION 'SLVC_TABLE_PS_TO_SPOOL'
EXPORTING
i_file_length = file_length
IMPORTING
e_spoolid = spool_id
TABLES
it_textdata = objbin.
IF sy-subrc EQ 0.
WRITE spool_id.
ENDIF.
DESCRIBE table objbin.
DATA PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = spool_id
NO_DIALOG = ' '
DST_DEVICE = 'MAIL'
* PDF_DESTINATION =
* IMPORTING
* PDF_BYTECOUNT = l_no_of_bytes
* PDF_SPOOLID = l_pdf_spoolid
* LIST_PAGECOUNT =
* BTC_JOBNAME =
* BTC_JOBCOUNT =
TABLES
PDF = pdf
EXCEPTIONS
ERR_NO_ABAP_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DESTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11
OTHERS = 12
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*Download PDF file C Drive
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\itab_to_pdf.pdf'
filetype = 'BIN'
TABLES
data_tab = pdf.
* Transfer the 132-long strings to 255-long strings
* LOOP AT pdf.
* TRANSLATE pdf USING ' ~'.
* CONCATENATE gd_buffer pdf INTO gd_buffer.
* ENDLOOP.
* TRANSLATE gd_buffer USING '~ '.
* DO.
* it_mess_att = gd_buffer.
* APPEND it_mess_att.
* SHIFT gd_buffer LEFT BY 255 PLACES.
* IF gd_buffer IS INITIAL.
* EXIT.
* ENDIF.
* ENDDO.
OBJHEAD = 'Objhead'.
append OBJHEAD.
* preparing email subject
concatenate W_ENDDA(6)
' Payslip-'
ITAB-ENAME+0(28)
ITAB-PERNR+4(4) ')'
into DOCDATA-OBJ_DESCR.
DOCDATA-OBJ_NAME = 'Pay Slip'.
DOCDATA-OBJ_LANGU = SY-LANGU.
OBJTXT = 'Pay Slip.'.
append OBJTXT.
*prepare email lines
OBJTXT = DOCDATA-OBJ_DESCR.
append OBJTXT.
OBJTXT = 'Please find enclosed your current payslip.'.
append OBJTXT.
* Write Attachment(Main)
* 3 has been fixed because OBJTXT has fix three lines
read table OBJTXT index 3.
* DOCDATA-DOC_SIZE = ( 3 - 1 ) * 255 + strlen( OBJTXT ).
clear OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = 3.
OBJPACK-DOC_TYPE = 'RAW'.
append OBJPACK.
* Create Message Attachment
ATT_TYPE = 'PDF'.
describe table OBJBIN lines TAB_LINES.
read table OBJBIN index TAB_LINES.
* OBJPACK-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + strlen( OBJBIN ).
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = ATT_TYPE.
OBJPACK-OBJ_NAME = 'ATTACHMENT'.
OBJPACK-OBJ_DESCR = 'Payslip'.
append OBJPACK.
* Create receiver list refresh RECLIST.
clear RECLIST.
RECLIST-RECEIVER = itab-USRID_long.
translate RECLIST-RECEIVER to lower case.
RECLIST-REC_TYPE = 'U'.
append RECLIST.
* Send the document
*SO_NEW_DOCUMENT_ATT_SEND_API1
call function 'SO_DOCUMENT_SEND_API1'
exporting
DOCUMENT_DATA = DOCDATA
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
tables
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = pdf
CONTENTS_TXT = OBJTXT
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
RECEIVERS = RECLIST
exceptions
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
others = 8.
if SY-SUBRC NE 0.
ITAB-MTEXT = 'Message Not Sent to : '.
else.
ITAB-MTEXT = 'Message Sent to : '.
endif.
* else.
* ITAB-MTEXT = 'Message Not Sent to : '.
* endif.
else.
"SY-SUBRC Not = 0
ITAB-MTEXT = 'Payroll data not found : '.
endif.
"end of SY-SUBRC = 0.
modify ITAB.
endloop. "end loop at ITAB
sort ITAB by MTEXT PERNR.
loop at ITAB.
at new MTEXT.
uline.
write : / ITAB-MTEXT color 4 intensified on.
write : / 'Emp. Code' color 2 intensified on,
12 'Emp. Name' color 2 intensified on,
54 'Email ID' color 2 intensified on.
endat.
write : / ITAB-PERNR, 12 ITAB-ENAME, 54 ITAB-USRID_LONG.
endloop. -
How to get internal table from SAP Data Provider C#
Hello.
ABAP:
DATA: lt_t001 TYPE TABLE OF t001.
DATA: url(1000) TYPE c.
SELECT * INTO TABLE lt_t001 FROM t001.
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'APPLICATION'
subtype = 'X-R3TABLE'
TABLES
data = lt_t001
CHANGING
url = url
EXCEPTIONS
OTHERS = 4.
C#:
using SAPDataProvider;
using SAPTableFactoryCtrl;
public void SetDataFromUrl(string url)
SAPDataProviderClass p = new SAPDataProviderClass();
p.SetDataFromURL("APPLICATION", "X-R3TABLE", url);
ISapDPR3Table tbl = p.GetDataAsR3Table("APPLICATION", "X-R3TABLE");
SAPTableFactoryClass tf = new SAPTableFactoryClass();
Table tb = (Table)tf.NewTable();
tb.ISAPrfcITab = tbl.DataTable; // Exception !!!!!!
How to get internal table from SAP Data Provider ?Hi Sergey,
I'm trying to do the same, have you found a solution to solved it?
thanks for your help.
Regards.
Jonathan -
How to Upload Excel sheet in DB or internal table using SAP NetWeaver ABAP
Dear All experts,
Pls provide guidance to Upload Excel sheet in DB or internal table using ABAP in ( SAP NetWeaver stack )
Regards
Machindra
Edited by: Machindra Patade on Apr 8, 2010 3:07 PMPlease search before posting.
Thread locked.
Thomas -
How to draw dynamic table in SAP Script !
Hi,
<i>I like to draw a table in the main window, the table height should depends on number of rows displayed on it.
Could any one please help on this.
Thank you,
Senthil</i>HI senthil
you have to use the BOX command in the SAPSCRIPT using which you can draw the table in script.
in the starting of the MAIN WINDOW draw a horizontal line and then display your vairables
in end again draw a horizontal line to close the table.
the height of the vertical line will the number of records in the internal table.
the vertical line can be drwan uisng
BOX XPOS 10 YPOS 20 width 0 CH hieght <rowcount> CH.
regards
kishore
regards
kishore -
Dynamic internal table in SAP 3.1I version
hi All,
i am new to this form and have the following question.
Currently i am working in SAP 3.1I version and i am required to create a dynamic internal table.
Basically the table name will be entered by the user on the selection screen and the dynamic internal table has to be of this type (entered by user on the selection screen).
Please let me know whether this is possible in 3.1I version and if its possible then how to achieve this.
Note: this requirement has to be done in 3.1I version hence OO concept (ie)
cl_alv_table_create=>create_dynamic_table doesn't work here.refer this demo code -
parameter p_table type tabname.
field-symbols <tab> type table.
field-symbols <tab1> type any.
types: begin of itab,
t_name type tabname,
t_ref type ref to data,
end of itab.
data itab1 type table of itab with non-unique key t_name.
perform fetch_data using p_table.
perform print_table using p_table.
*& Form fetch_data
text
-->P_P_TABLE text
FORM fetch_data USING P_TABLE1 type tabname.
data itab2 type itab.
itab2-t_name = p_table1.
create data itab2-t_ref type table of (itab2-t_name) .
assign itab2-t_ref->* to <tab>.
append itab2 to itab1.
select * from (p_table1) up to 25 rows into corresponding fields of table <tab>.
ENDFORM. " fetch_data
*& Form print_table
text
-->P_P_TABLE text
FORM print_table USING P_TABLE1 type tabname.
DATA t_ref1 TYPE REF TO data.
DATA itab2 TYPE itab.
FIELD-SYMBOLS <field> TYPE ANY.
READ TABLE itab1 INTO itab2 WITH KEY t_name = p_table1.
ASSIGN itab2-t_ref->* TO <tab>.
CREATE DATA t_ref1 LIKE LINE OF <tab>.
ASSIGN t_ref1->* TO <tab1>.
DO.
*READ TABLE <tab> ASSIGNING <tab1> INDEX 1.
READ TABLE <tab> ASSIGNING <tab1> INDEX SY-INDEX.
*WRITE:/ p_table1.
NEW-LINE.
IF sy-subrc <> 0.
EXIT.
ENDIF.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE <tab1> TO <field>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
WRITE: <field>,' '.
ENDDO.
ENDDO.
ENDFORM. " print_table -
Function module to upload excel to internal table in SAP 7.0 version system
<<Question has been asked and answered many times - please search before asking for function modules for common tasks>>
currently i am using SAP Netweaver7.0 version, i need a Funtion Module to upload an Excel sheet data to an internal table.
please let me know this ASAP.
thanks,
Edited by: Matt on Aug 24, 2009 7:25 AMhi,
the FM you have suggested does not exist in the *version 7.0*
added the FM "ALSM_....",also does not exist
pls suggest a FM for SAP7.0 version -
How can create a table in sap script?
Hi,
How to create a table in the sap script.i Have to use table in the main window with 11 rows and 3 columns. can any one send sample code. Any ideas?¿
THKS 4all.Try and check on the below logic....
1. write -
2. write headings with '|' at start and end as well as the field separator.
3. write -
4. similar to step two write the data with pipe separators.
5. write -
regards
Anurag -
Dyanamic table is SAP Script with horizontal and vertical lines
Hi,
I need to display the data of the table in the SAP script which is having both horiziontal and vertival lines.
the out put needs to looks as it in Excel...where there are multiple records with 5 fixed coulmns each seprated from one another by horizonalt and vertical lines..
I thinking about useing the Box with XPOS and YPOS who value changes dynamicaaly..
But again as the number of pages might be more than one..i think there will issues,
Can you let me know how to proceed in SCRIPT ,,,, where the number of records might vary ..and also ..it might continue to second page..
Regards
Senthilwell it is possible but quite tricky.
All you got in SAP-SCRIPT to achieve this is the BOX-Statement.
The BOX statement works with variables for XPOS, YPOS, WIDTH and HEIGHT. what you need to do is:
- calculate those variables during runtime
- add box-statements with those variables.
to calculate those variables you need to count used lines and so on. i hope i showed you a way, rest is a lil brainwork then.
regards -
How to make use of a global internal table in SAP BW during transfer rules
HI friends,
I am ABAP consultant working on some APO info cubes. I have an issue during the upload of planning area data into APO info cube.
Please help.
I am using a transfer routine to find the TECHWEEK from a data base table ZGC_CALWEEK based on the on the calender month and calender week.
Code I am writing is like below.
* FORM COMPUTE_/BIC/ZCALWEEK
* Compute value of InfoObject ZCALWEEK
* in communication structure /BIC/CSZT6DPPA
* Technical properties:
* field name = /BIC/ZCALWEEK
* data element = /BIC/OIZCALWEEK
* data type = NUMC
* length = 000006
* decimals = 000000
* ABAP type = N
* ABAP length = 000006
* reference field =
* Parameters:
* --> RECORD_NO Record number
* --> TRAN_STRUCTURE Transfer structure
* <-- RESULT Return value of InfoObject
* <-> G_T_ERRORLOG Error log
* <-- RETURNCODE Return code (to skip one record)
* <-- ABORT Abort code (to skip whole data package)
FORM COMPUTE_/BIC/ZCALWEEK
USING RECORD_NO LIKE SY-TABIX
TRAN_STRUCTURE TYPE TRANSFER_STRUCTURE
G_S_MINFO TYPE RSSM_S_MINFO
CHANGING RESULT TYPE /BIC/OIZCALWEEK
G_T_ERRORLOG TYPE rssm_t_errorlog_int
RETURNCODE LIKE SY-SUBRC
ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel datapackage
*$*$ begin of routine - insert your code only below this line *-*
* DATA: l_s_errorlog TYPE rssm_s_errorlog_int.
DATA: LV_WEEK TYPE ZGC_CALWEEK-APOWEEK,
LV_MONTH TYPE ZGC_CALWEEK-APOMONTH,
LV_TECH_WEEK TYPE ZGC_CALWEEK-TECHWEEK.
LV_WEEK = TRAN_STRUCTURE-CALWEEK.
LV_MONTH = TRAN_STRUCTURE-CALMONTH.
SELECT SINGLE TECHWEEK INTO LV_TECH_WEEK
FROM ZGC_CALWEEK CLIENT SPECIFIED
WHERE MANDT = SY-MANDT
AND APOWEEK = LV_WEEK
AND APOMONTH = LV_MONTH.
IF SY-SUBRC IS INITIAL.
RESULT = LV_TECH_WEEK.
ELSE.
RETURNCODE = 1.
ENDIF.
*$*$ end of routine - insert your code only before this line *-*
ENDFORM.
There are more than 50-80 million records that wil be transferred from planning area to info cube. The select statment is giving pathetic performance as this has to run 50-80 million times.
After adding the select statment to find the TECHWEEK it is taking 4 times the time that used to take before writing the select statment.
Is there a way that I can first fetch the data from ZGC_CALWEEK to one internal table and that internal table can be used using read statment during the transfer routine instead of writing select statement here.
Please help in this case?Hi Ashutosh,
Thanks for the reply,
The structure of the ZGC_CALWEEK is as below. I have already created a secondary index on the table for this table for the fields APO WEEK and APO MONTH. This didn't help much on the performance.
I am also planning to keep the ZGC_CALWEEK database table to be fully buffered and this may definitely improve the performance but I need to reduce the data base hits as less as possible.
MANDT MANDT CLNT 3 0 Client
TECHWEEK ZTECHWEEK NUMC 6 0 Technical Week
FROMDATE_TECH DATUM DATS 8 0 Date
TODATE_TECH DATUM DATS 8 0 Date
APOWEEK /BI0/OICALWEEK NUMC 6 0 Calendar year / week
FROMDATE_APO DATUM DATS 8 0 Date
TODATE_APO DATUM DATS 8 0 Date
APOMONTH /BI0/OICALMONTH NUMC 6 0 Calendar year/month
The table ZGC_CALWEEK is in APO system, where the transfer rules are being executed.
As you mentioned START ROUTINE, In the start routine Can I create an internal table let's say GT_CALWEEK with structure ZGC_CALWEEK and pull all the records (I have a max of 2000 records in this table) from ZGC_CALWEEK to GT_CALWEEK and Can I used the same internal table GT_CALWEEK in the transfer routine to read the TECHWEEK from internal table.
Thank you very much again for you reply. Any help regarding this would be greatly appreciated.
Best regards,
Siva -
Table where Sap-Script Paragraph formats are stored
hey ABAP,
does anyone know the table where the Paragraph formats are stored?
Problem: we have a Form with 740 Paragraph formats, they all are of font-type courier, and now need to be either blank or Helve.
and well i simply dont want to change 740 paragraph formats manually.
thx for any ideas, hintsarrrgh ok i´m trying to clarify my situation.
I already know how to create and edit paragraph formats in SE71.
Those 740 Paragraph formats have been created by myself.
But now i need to make a change of the Font type to all of them.
you sureley can imagine that i dont want to edit 740 paragraph formats manually piece by piece.
thats why i was asking for a table where they are stored, so i can write a small report which changes that one field for me in ALL my pareagraph formats. -
SAP Script .........Need Example
Hii Guyz..
Can anybody tell me how to print line items one by one from internal table into SAP script....
eg.
No. name quant..
1 xyz 5
2 sdf 7
etc./E ITEM -
Start of Text Element
/: TOP
/: POSITION WINDOW
/: BOX WIDTH '185' MM HEIGHT '10' MM FRAME 10 TW
P3 ,,Qty,,Description/Invoice for Customs,,Product Ref/Serial No.,,Unit
Price,,Net Amount,,Vat Rate
/: IF &PAGE& = '1'
/: BOX YPOS '10' MM WIDTH '185' MM HEIGHT '97' MM FRAME 10 TW
/: ELSE
/: BOX YPOS '10' MM WIDTH '185' MM HEIGHT '220' MM FRAME 10 TW
/: ENDIF
/: ENDTOP
/: BOTTOM
/* IF &W_FLAG8& = ''
P7 ,,,,,,,,,,,,,,,,,,,,,,,,Transactions continue on Page &NEXTPAGE&
/* ENDIF
/: ENDBOTTOM
/: PROTECT
M1 ,,&w_vbrp-fkimg1&,,&w_vbrp-arktx&,,&w_vbrp-matnr&,,&W_VBRp-KZWI2&,,
the above logic has to be written in a SAPSCRIPT Form and below u have to write in the calling program
LOOP...
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'ITEM'
window = 'MAIN'.
ENDLOOP.
Make sure u use Main Window for printing it.
Message was edited by:
Utsah Garg -
Convert XML to SAP internal table
Hi gurus,
My program is suppose to get current exchange rate file from website and upload it in SAP.
by using FM 'HTTP_GET', im getting the data in XML format.My problem is..i have tried to use transformation but failed to
map it against XML data element..and i have tried to use CALL FUNCTION 'SCMS_TEXT_TO_XSTRING' and then CALL FUNCTION 'SMUM_XML_PARSE' but it returns initial value with error ''line 0 col 12-unexpected symbol: '>'' .
Below is an excerpt of my XML file:
..<xml version>
..<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
.. xmlns:o="urn:schemas-microsoft-com:office:office"
.. xmlns:x="urn:schemas- microsoft-com:office:excel"
.. xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
.. <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"> <WindowHeight>10875</WindowHeight>........ <WindowWidth>13260</WindowWidth><WindowTopX>480</WindowTopX><WindowTopY>30</Wind
.. <Style ss:ID="Default" ss:Name="Normal">
.. <Alignment ss:Vertical="Bottom"/>
.. <Borders/>
.. <Font/>
.. <Interior/>
.. <NumberFormat/>
.. <Protection/>
.. </Style>
.. <Style ss:ID="BoldColumn">
.. <Font ss:FontName="Microsoft Sans Serif" x:Family="Swiss" ss:Bold="1"/>
.. <Worksheet ss:Name="Page1"><Table ss:StyleID="s21" > <Column ss:Width="130"/> <Column ss:Width="85"/> <Column .. ss:Width="85"/> <Column ss:Width="85"/> <Column ss:Widt
.. Cell><Cell ss:MergeAcross="1" ss:StyleID="BoldColumn"><Data ss:Type="String">Average Buying Rates</Data></Cell><Cell .. ss:MergeDown="1" ss:StyleID="BoldColumn"><Data ss:Type="Stri
.. ss:Type="Number">47.3732</Data></Cell><Cell ss:StyleID="Decimal"><Data ss:Type="Number">47.5374</Data></Cell><Cell .. ss:StyleID="Decimal"><Data ss:Type="Number">48.2323</Data></Ce
.. " ><Data ss:Type="String">HONG KONG</Data></Cell><Cell ss:StyleID="StringLiteralCenter" ><Data .. .. ss:Type="String">HKD</Data></Cell><Cell ss:StyleID="Decimal"><Data ss:Type="Numb
.. ss:Type="Number">22.8131</Data></Cell><Cell ss:StyleID="Decimal"><Data ss:Type="Number">23.2595</Data></Cell>.. .. </Row><Row><Cell ss:StyleID="StringLiteral" ><Data ss:Type="String"
.. ss:StyleID="StringLiteralCenter" ><Data ss:Type="String">IDR</Data></Cell><Cell ss:StyleID="Decimal"><Data .. ss:Type="Number">3.0395</Data></Cell><Cell ss:StyleID="Decimal"><Data
.. ecimal"><Data ss:Type="Number">30.6424</Data></Cell></Row><Row><Cell ss:StyleID="StringLiteral" ><Data .. ss:Type="String">AUSTRALIA</Data></Cell><Cell ss:StyleID="StringLiteralCe
.. ell ss:StyleID="Decimal"><Data ss:Type="Number">0.3392</Data></Cell><Cell ss:StyleID="Decimal"><Data .. ss:Type="Number">0.3409</Data></Cell><Cell ss:StyleID="Decimal"><Data ss:Typ
.. StringLiteral" ><Data ss:Type="String">DENMARK</Data></Cell><Cell ss:StyleID="StringLiteralCenter" ><Data .. ss:Type="String">DKK</Data></Cell><Cell ss:StyleID="Decimal"><Data ss
.. ata ss:Type="Number">4.4550</Data></Cell><Cell ss:StyleID="Decimal"><Data ss:Type="Number">4.6073</Data></Cell>.. </Row><Row></Row><Row></Row><Row><Cell ss:MergeAcross="4" ss:Style
.. s of 23 November 2010</Data></Cell></Row><Row></Row><Row><Cell ss:MergeAcross="4" .. ss:StyleID="BoldColumn_Left" ><Data ss:Type="String">2. Foreign Exchange Rates (THOMSON REUTE
.. ><Data ss:Type="String">ZAR</Data></Cell><Cell ss:StyleID="Decimal"><Data ss:Type="Number">4.2735</Data></Cell>.. <Cell ss:StyleID="Decimal"><Data ss:Type="Number">4.3125</Data></
.. ="Decimal"><Data ss:Type="Number">106.5459</Data></Cell><Cell ss:StyleID="Decimal"><Data .. ss:Type="Number">107.5164</Data></Cell></Row><Row><Cell ss:StyleID="StringLiteral" ><Da
.. a></Cell><Cell ss:StyleID="Decimal"><Data ss:Type="Number">4.6916</Data></Cell></Row><Row><Cell .. ss:StyleID="StringLiteral" ><Data ss:Type="String">BANGLADESH</Data></Cell><Cell
.. r">0.0074</Data></Cell></Row><Row><Cell ss:StyleID="StringLiteral" ><Data ss:Type="String">KENYA</Data></Cell><Cell .. ss:StyleID="StringLiteralCenter" ><Data ss:Type="String">KE
.. ><Cell ss:StyleID="StringLiteral" ><Data ss:Type="String">VIET NAM</Data></Cell><Cell ss:StyleID="StringLiteralCenter" >.. <Data ss:Type="String">VND</Data></Cell><Cell ss:StyleI
.. A</Data></Cell><Cell ss:StyleID="StringLiteralCenter" ><Data ss:Type="String">LKR</Data></Cell><Cell .. .. ss:StyleID="Decimal"><Data ss:Type="Number">0.2686</Data></Cell><Cell ss:St
.. String">OMR</Data></Cell><Cell ss:StyleID="Decimal"><Data ss:Type="Number">77.7094</Data></Cell><Cell
Please help me to translate my XML file into SAP format...i need it fixed urgently..
Edited by: Guest101 on Dec 28, 2010 12:11 PMIt has 2 part one is source code and another is the XML file
create an XML file with the data provided in the last 2.
then place it in a path mention the path in the below source.
1. Complete code for converting XML to internal table in SAP.
*& Report ZTST_PGM02
REPORT ZTST_PGM02.
Load iXML Lib.
type-pools: ixml.
class cl_ixml definition load.
data: G_IXML type ref to if_ixml.
data: STREAMFACTORY type ref to if_ixml_stream_factory.
data: ISTREAM type ref to if_ixml_istream.
data: DOCUMENT type ref to if_ixml_document.
data: PARSER type ref to if_ixml_parser.
data: LV_FILE_URL type rlgrap-filename.
You should provide the parameter for file name
LV_FILE_URL = 'D:\navps\input_xml.xml'.
types: begin of XML_LINE,
DATA(256) type x,
end of XML_LINE.
types: begin of TY_HEADER,
CUST_NAME(20) type c,
CARD_NO(20) type c,
TAX_AMOUNT(10) type c,
TOTAL_AMOUNT(10) type c,
end of TY_HEADER.
types: begin of TY_ITEM,
ITEM_NO(4) type n,
ITEM_ID(20) type c,
ITEM_TITLE(50) type c,
ITEM_QTY(10) type c,
ITEM_UPRICE(10) type c,
end of TY_ITEM.
data: GV_HEADER type TY_HEADER.
data: GT_ITEM type standard table of TY_ITEM with header line.
data: XML_TABLE type table of XML_LINE,
XML_TABLE_SIZE type i.
The next step is creating the main factory for the iXML library:
G_IXML = cl_ixml=>create( ).
Now Create Stream Factory
STREAMFACTORY = G_IXML->create_stream_factory( ).
upload a file from the client's workstation
call function 'WS_UPLOAD'
exporting
filename = LV_FILE_URL
filetype = 'BIN'
importing
filelength = XML_TABLE_SIZE
tables
data_tab = XML_TABLE
exceptions
others = 11.
wrap the table containing the file into a stream
ISTREAM = STREAMFACTORY->create_istream_itable( table = XML_TABLE
size = XML_TABLE_SIZE )
Get the file data as Stream
*istream = streamfactory->create_istream_uri( public_id = lv_file_url
system_id = lv_file_url ).
Create XML Document instance
DOCUMENT = G_IXML->create_document( ).
Create parser Object
PARSER = G_IXML->create_parser( stream_factory = STREAMFACTORY
ISTREAM = istream
DOCUMENT = document ).
Parse an XML document into a DOM tree
*parser->parse( ).
Parsing Error Processing
if PARSER->parse( ) ne 0.
if PARSER->num_errors( ) ne 0.
data: PARSEERROR type ref to if_ixml_parse_error,
STR type STRING,
I type i,
COUNT type I,
INDEX type i.
COUNT = PARSER->num_errors( ).
write: COUNT, ' parse errors have occured:'.
INDEX = 0.
while INDEX < COUNT.
PARSEERROR = PARSER->get_error( INDEX = index ).
I = PARSEERROR->get_line( ).
write: 'line: ', i.
I = PARSEERROR->get_column( ).
write: 'column: ', i.
STR = PARSEERROR->get_reason( ).
write: STR.
INDEX = index + 1.
endwhile.
endif.
endif.
Close the stream since it #s not needed anymore
call method ISTREAM->close( ).
clear ISTREAM.
Now try to make it look good
data : lv_size type sytabix,
lv_ret_code type sysubrc.
data: lo_xml_document type ref to cl_xml_document.
field-symbols: <fs_xml_data> type any table.
lo_xml_document = document.
call method lo_xml_document->get_as_table
importing
table = <fs_xml_data>
size = lv_size
retcode = lv_ret_code
*data: items type ref to if_ixml_node_collection.
*items = document->get_elements_by_tag_name( name = 'Item' ).
*data: iterator type ref to if_ixml_node_iterator,
node type ref to if_ixml_node.
*iterator = document->create_iterator( ).
*node = iterator->get_next( ).
*while not node is initial.
do something with the node
node = iterator->get_next( ).
*endwhile.
DATA : GV_NODE type ref to if_ixml_node.
DATA : GV_NODETEXT type STRING.
data: GV_FIRST_TIME.
GV_FIRST_TIME = 'X'.
GV_NODE = DOCUMENT.
GT_ITEM-item_no = 1.
perform GET_DATA tables GT_ITEM
using GV_NODE
changing GV_HEADER.
Last item is still not added.
append GT_ITEM.
write : GV_HEADER-cust_name,
GV_HEADER-card_no,
GV_HEADER-tax_amount,
GV_HEADER-total_amount.
loop at GT_ITEM.
write /:.
write : GT_ITEM-item_no,
GT_ITEM-item_id,
GT_ITEM-item_title,
GT_ITEM-item_qty,
GT_ITEM-item_uprice.
endloop.
FORM Get_data *
form get_data tables YT_ITEM structure GT_ITEM
using value(x_node) type ref to if_ixml_node
changing Y_HEADER type TY_HEADER.
data: INDENT type i.
data: PTEXT type ref to if_ixml_text.
data: STRING type string.
data: TEMP_STRING(100).
case X_NODE->get_type( ).
when if_ixml_node=>co_node_element.
STRING = X_NODE->get_name( ).
GV_NODETEXT = STRING.
when if_ixml_node=>co_node_text.
PTEXT ?= X_NODE->query_interface( IXML_IID_TEXT ).
if PTEXT->ws_only( ) is initial.
STRING = X_NODE->get_value( ).
case GV_NODETEXT.
when 'Customer'.
clear GV_HEADER.
when 'Name'.
move STRING to GV_HEADER-cust_name.
when 'Cardnum'.
move STRING to GV_HEADER-card_no.
when 'Tax'.
move STRING to GV_HEADER-tax_amount.
when 'Total'.
move STRING to GV_HEADER-total_amount.
Iteam details
when 'ID'.
move STRING to GT_ITEM-item_id.
when 'Title'.
move STRING to TEMP_STRING.
move TEMP_STRING to GT_ITEM-item_title.
when 'Quantity'.
move STRING to GT_ITEM-item_qty.
when 'UnitPrice'.
move STRING to GT_ITEM-item_uprice.
endcase.
endif.
endcase.
if GV_NODETEXT = 'Customer'.
clear GV_HEADER.
elseif GV_NODETEXT = 'Item'.
if GV_FIRST_TIME ne 'X'.
append GT_ITEM.
clear : gt_item.
GT_ITEM-item_no = gt_item-item_no + 1.
endif.
GV_FIRST_TIME = ' '.
endif.
Get the next child
X_NODE = x_node->get_first_child( ).
Recurse
while not X_NODE is initial.
perform GET_DATA tables GT_ITEM
using X_NODE
changing GV_HEADER.
X_NODE = x_node->get_next( ).
endwhile.
endform.
Create an XML file with the following DATA given below and place it in the path mentioned above source code.
2. XML File DATA. You create an XML File in this format to test the same.
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>
- <Order>
- <Customer>
<Name>Bill Buckram</Name>
<Cardnum>234 234 234 234</Cardnum>
</Customer>
- <Manifest>
- <Item>
<ID>209</ID>
<Title>Duke: A Biography of the Java Evangelist</Title>
<Quantity>1</Quantity>
<UnitPrice>$10.75</UnitPrice>
</Item>
- <Item>
<ID>208</ID>
<Title>100% Pure: Making Cross Platform Deployment a Reality</Title>
<Quantity>1</Quantity>
<UnitPrice>$10.75</UnitPrice>
</Item>
- <Item>
<ID>204</ID>
<Title>Making the Transition from C++ to the Java(tm) Language</Title>
<Quantity>1</Quantity>
<UnitPrice>$10.75</UnitPrice>
</Item>
- <Item>
<ID>202</ID>
<Title>Web Servers for Fun and Profit</Title>
<Quantity>1</Quantity>
<UnitPrice>$10.75</UnitPrice>
</Item>
- <Item>
<ID>210</ID>
<Title>I Think Not: Dukes Likeness to the Federation Insignia</Title>
<Quantity>1</Quantity>
<UnitPrice>$10.75</UnitPrice>
</Item>
</Manifest>
- <Receipt>
<Subtotal>$53.75</Subtotal>
<Tax>$4.43</Tax>
<Total>$58.18</Total>
</Receipt>
</Order> -
Writing Cleint side scripting to edit internal table
Hello Gurus
I have a internal table which i am displaying in tableview . i want to add record into the itab when i i click on one button on the form.
I want to do it this action in the client side using abap script of java script.
I am not sure how to handle internal table with java script. and one more question is that how to write client side abap script.?
Is there any recommendation?
Thanks
HariI guess you didn't quiet understand my question.
1. Can i access page attribute s( ex:iinternal table ,or string variable ) in the client script.( java script which runs on client browser ).
2. If the above answer is yes, how to add a record into intertal table with java code . ( syntax ) .
Thanks for the help.
Thanks
Hari
Maybe you are looking for
-
How can I install gutenprint drivers for my Epson Stylus Color 440?
Good day all! I have and old and useful printer -Epson Stylus Color 440- and just bougth a cable for connecting it to USB port. Add a new print on its Print and Scan Preference Panel and it was recognized inmediatly, but I was told there was not any
-
How to rotate and transform bar graphs without distorsion?
I have a horizontal bar graphic and I want to make it have the same shape than a circular graphic that I have as background. What I do first is to rotate the graph (after converting it in an image) to the right angle, depending on where it has to be
-
Every time I boot up my MBA, there is a logon screen asking for the user: me or Guest User. The mouse is working but cannot select the user and I need to use the keyboard to select the user. Can I skip this screen and show the password screen direc
-
Audio driver doesn't work for my compaq presario r4000 notebook XP system
Hello, I just reinstall Window XP on my compaq presario r4000 notebook, and I download all the drivers from HpCompaq offical website. But the audio driver does't work for my "Conexant AC-Link Audio (PCI\VEN_1002&DEV_4370&SUBSYS_3085103C&REV_01\3&13C0
-
Laserjet 4200dtn after change driver Have a problem with windowsXP
Laser jet 4200 dtn and windows server 2003 Hi, The last week In accord with your chat support I change the driver of my Hp 4200 dtn from P6 to PS. You told me that the PS driver is better to print with .pdf files and to print the layout like book A