工作生活与爱好

工作中的记录; 生活中的记忆; 业余爱好的记载。

2007-01-16

 

如何在REUSE_ALV_GRID_DISPLAY标识不同行用不同的颜色

1 在内表中加入颜色字段
.............................
color(4) type c,
................................

2 在内表添加记录是通过条件设置颜色字段值
wa_customerinfo-color = 'C110'.

3 设置颜色控制内表 slis_layout_alv 的颜色字段为内表增加的颜色字段
data g_slis_layo type slis_layout_alv. "定义Grid输出颜色控制内表
g_slis_layo-info_fieldname = 'COLOR'.

4 输出记录
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
is_layout = g_slis_layo
it_fieldcat = g_field[]
it_sort = g_sort[]
it_events = event_top_of_page[]
tables
t_outtab = i_customerinfo.

以下为显示表头的代码
data event_top_of_page type slis_alv_event occurs 0 with header line.
perform event_top_of_page tables event_top_of_page.

form event_top_of_page tables rt_event type slis_t_event.
refresh rt_event.
clear rt_event.
rt_event-name = slis_ev_top_of_page.
rt_event-form = 'WRITE_TOP_OF_PAGE'.
append rt_event.
endform. "event_top_of_page

form write_top_of_page.
data: hline type slis_listheader,
text(60) type c,
text10(10) type c,
text5(5) type c,
percent type p decimals 2.

refresh head.
clear head.
clear: hline, text.
hline-typ = 'S'.
write: '时间:', g_curdate to text.
hline-info = text.
append hline to head.
write: '客户状态:绿色-老呆死客户,红色-新呆死客户,兰色-超信用额度客户'
to text.
hline-info = text.
write: g_countkunnr to text5.
append hline to head.
concatenate '往来单位:' text5 '个.' into text.
hline-info = text.
append hline to head.
write: g_oldbad_count to text5.
concatenate '老呆死帐单位:' text5 '个,占' into text.
percent = g_oldbad_count * 100 / g_countkunnr.
write: percent to text5.
concatenate text5 '%' into text+23.
write: g_newbad_count to text5.
concatenate '新呆死单位:' text5 '个,占' into text+30.
percent = g_newbad_count * 100 / g_countkunnr.
write: percent to text5.
concatenate text5 '%' into text+53.
* CONDENSE text.
hline-info = text.
append hline to head.
clear text.
percent = g_ccdebit_count / 10000.
write: percent to text10.
concatenate '应收帐款:' text10 '万元' into text.
percent = g_webtr_count / 10000.
write: percent to text10.
concatenate '认可呆死帐:' text10 '万元.' into text+30.
hline-info = text.
append hline to head.

percent = g_oldbad_money / 10000.
write: percent to text10.
concatenate '老呆死帐款:' text10 '万元,' into text.
percent = g_oldbad_money * 100 / g_ccdebit_count.
write: percent to text5.
concatenate '占' text5 '%' into text+30.
hline-info = text.
append hline to head.

percent = g_newbad_money / 10000.
write: percent to text10.
concatenate '新呆死帐款:' text10 '万元,' into text.
percent = g_newbad_money * 100 / g_ccdebit_count.
write: percent to text5.
concatenate '占' text5 '%' into text+30.
hline-info = text.
append hline to head.

write: g_over_count to text5.
concatenate '超安全额度单位:' text5 '个,' into text.
percent = g_over_count * 100 / g_countkunnr.
write: percent to text5.
concatenate '占' text5 '%' into text+24.
percent = g_over_money / 10000.
write: percent to text10.
concatenate '超安全额度:' text10 '万元.' into text+30.
hline-info = text.
append hline to head.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = head.
endform. "write_top_of_page


 

比较全面的ALV Function方式的

*----------------------------------------------------------------------
* Program: ZZ_ALV_REPORT_STUB
* Author : Clayton Mergen
* Date :
*
* Purpose: Report using ALV function
*
* Notes:
* 1) Logos & wallpapers can be found in table BDS_CONN05
* with class = PICTURES
*
* 2) Transaction OAER can be used to create PICTURES.
* Run transaction OAER with class name = PICTURES, Class type = OT,
* and Object key with whatever name you want to create. In the
* next screen, right clicking on screen and import
*
*----------------------------------------------------------------------
* Revisions
*----------------------------------------------------------------------
* Name :
* Date :
* Comments:
*----------------------------------------------------------------------
report zz_alv_report_stub
no standard page heading
line-size 200
line-count 65
message-id zz.

*--------------------------------
* Tables
*--------------------------------
tables:
ekpo,
trdir.

*--------------------------------
* Global Types
*--------------------------------
type-pools: slis.

*--------------------------------
* Global Internal Tables
*--------------------------------
data:
i_fieldcat_alv type slis_t_fieldcat_alv,
i_events type slis_t_event,
i_event_exit type slis_t_event_exit,
i_list_comments type slis_t_listheader,
i_excluding type slis_t_extab.

* Display data
data: begin of i_data occurs 0,
name like trdir-name,
clas like trdir-clas,
subc like trdir-subc,
cnam like trdir-cnam,
cdat like trdir-cdat,
myfield(1) type c,
end of i_data.

*--------------------------------
* Global Variables
*--------------------------------
data:
w_variant like disvariant,
wx_variant like disvariant,
w_variant_save(1) type c,
w_exit(1) type c,
w_repid like sy-repid,
w_user_specific(1) type c,
w_callback_ucomm type slis_formname,
w_print type slis_print_alv,
w_layout type slis_layout_alv,
w_html_top_of_page type slis_formname,
w_fieldcat_alv like line of i_fieldcat_alv,
w_excluding like line of i_excluding,
w_events like line of i_events,
w_event_exit like line of i_event_exit,
w_list_comments like line of i_list_comments.

*--------------------------------
* Global Constants
*--------------------------------
*constants:

*--------------------------------
* Selection Screen
*--------------------------------
selection-screen begin of block blk_criteria with frame title text-f01.
select-options:
s_name for trdir-name.
selection-screen end of block blk_criteria.

selection-screen begin of block blk_params with frame title text-f02.
parameters:
p_vari like disvariant-variant.
selection-screen skip 1.
parameters:
p_grid radiobutton group rb01 default 'X',
p_html as checkbox.
selection-screen skip 1.
parameters:
p_list radiobutton group rb01.
selection-screen end of block blk_params.

*--------------------------------
* Initialization
*--------------------------------
initialization.
perform init_variant.
perform variant_default using p_vari.

clear: s_name[].
s_name-sign = 'I'.
s_name-option = 'CP'.
s_name-low = 'Z*'.
append s_name.

*--------------------------------
* At Selection Screen PBO
*--------------------------------
at selection-screen output.

*----------------------------------
* At Selection Screen Value Request
*----------------------------------
at selection-screen on value-request for p_vari.
perform variant_f4 using p_vari.

*--------------------------------
* At Selection Screen
*--------------------------------
at selection-screen.
perform variant_fill.

*--------------------------------
* Start of Selection
*--------------------------------
start-of-selection.
perform get_data.

end-of-selection.
perform fieldcat_build.
perform event_build.
perform event_exit_build.
perform exclude_build.
perform print_build.
perform layout_build.
perform display_data.

*--------------------------------
* Top of Page
*--------------------------------
top-of-page.

*--------------------------------
* Top of Page During Line Sel
*--------------------------------
top-of-page during line-selection.

*--------------------------------
* At User Command
*--------------------------------
at user-command.

*--------------------------------
* At Line Selection
*--------------------------------
at line-selection.

*--------------------------------
* Macros
*--------------------------------
define skip_1.
write: /001 sy-vline,
at sy-linsz sy-vline.
end-of-definition.

*----------------------------------------------------------------------
* Forms
*----------------------------------------------------------------------
*&---------------------------------------------------------------------*
*& Form variant_f4
*&---------------------------------------------------------------------*
form variant_f4 using p_variant.

call function 'LVC_VARIANT_F4'
exporting
is_variant = w_variant
i_save = w_variant_save
importing
e_exit = w_exit
es_variant = wx_variant
exceptions
not_found = 1
program_error = 2
others = 3.

if sy-subrc <> 0.
message i000(zz) with text-g01.
endif.

if w_exit is initial.
w_variant-variant = wx_variant-variant.
p_variant = wx_variant-variant.
endif.

endform.
*&---------------------------------------------------------------------*
*& Form init_variant
*&---------------------------------------------------------------------*
form init_variant.

clear: w_variant.
w_repid = sy-repid.
w_variant-report = w_repid.
w_variant-username = sy-uname.
w_variant_save = 'A'. "All types

endform.
*&---------------------------------------------------------------------*
*& Form variant_default
*&---------------------------------------------------------------------*
form variant_default using p_variant.

wx_variant = w_variant.

if not p_variant is initial.
wx_variant-variant = p_variant.
endif.

call function 'LVC_VARIANT_DEFAULT_GET'
exporting
i_save = w_variant_save
changing
cs_variant = wx_variant
exceptions
wrong_input = 1
not_found = 2
program_error = 3
others = 4.

case sy-subrc.
when 0.
p_variant = wx_variant-variant.
when 2.
clear: p_variant.
endcase.

endform.
*&---------------------------------------------------------------------*
*& Form variant_fill
*&---------------------------------------------------------------------*
form variant_fill.

clear: w_variant.

if p_vari is initial.
w_variant-variant = 'STANDARD'.
w_variant-report = w_repid.
else.

w_variant-variant = p_vari.
w_variant-report = w_repid.

call function 'LVC_VARIANT_EXISTENCE_CHECK'
exporting
i_save = w_variant_save
changing
cs_variant = w_variant
exceptions
others = 01.
if sy-subrc ne 0.
message i000(zz) with text-g02.
endif.
endif.

endform.
*&---------------------------------------------------------------------*
*& Form fieldcat_build
*&---------------------------------------------------------------------*
form fieldcat_build.

call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = w_repid
* i_structure_name = 'TRDIR'
i_internal_tabname = 'I_DATA'
i_inclname = w_repid
changing
ct_fieldcat = i_fieldcat_alv.

* Modify displayed fields
loop at i_fieldcat_alv into w_fieldcat_alv.
case w_fieldcat_alv-fieldname.
when 'NAME'.
w_fieldcat_alv-hotspot = 'X'.
when 'MYFIELD'.
w_fieldcat_alv-checkbox = 'X'.
w_fieldcat_alv-seltext_s = 'MyChkBox'.
when others.
endcase.

modify i_fieldcat_alv from w_fieldcat_alv.
endloop.

endform.
*&---------------------------------------------------------------------*
*& Form display_data
*&---------------------------------------------------------------------*
form display_data.

w_callback_ucomm = 'CALLBACK_UCOMM'.

case 'X'.
when p_grid.
if p_html = 'X'.
w_html_top_of_page = 'HTML_TOP_OF_PAGE'.
endif.

call function 'REUSE_ALV_GRID_DISPLAY'
exporting
* i_background_id = 'SIWB_WALLPAPER'
i_background_id = 'SIWB_WALLPAPER'
i_callback_program = w_repid
i_callback_html_top_of_page = w_html_top_of_page
* i_structure_name = 'TRDIR'
i_default = 'X'
i_save = 'A'
is_variant = w_variant
is_layout = w_layout
i_callback_user_command = w_callback_ucomm
it_fieldcat = i_fieldcat_alv
it_events = i_events
it_event_exit = i_event_exit
it_excluding = i_excluding
is_print = w_print
* i_screen_start_column = 1
* i_screen_start_line = 1
* i_screen_end_column = 70
* i_screen_end_line = 30
tables
t_outtab = i_data.

when p_list.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_background_id = 'ALV_BACKGROUND'
i_callback_program = w_repid
i_default = 'X'
i_save = 'A'
is_variant = w_variant
is_layout = w_layout
i_callback_user_command = w_callback_ucomm
it_fieldcat = i_fieldcat_alv
it_events = i_events
it_event_exit = i_event_exit
is_print = w_print
tables
t_outtab = i_data.
endcase.

endform.
*---------------------------------------------------------------------*
* FORM user_command *
*---------------------------------------------------------------------*
form callback_ucomm using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.

message i000(zz) with r_ucomm.

case r_ucomm.
when '&IC1'.
set parameter id 'RID' field rs_selfield-value.
call transaction 'SE38'.
when others.
endcase.

endform.
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
form get_data.

select * up to 15 rows from trdir
into corresponding fields of table i_data
where name in s_name.

endform.
*---------------------------------------------------------------------*
* FORM ALV_TOP_OF_PAGE *
*---------------------------------------------------------------------*
form alv_top_of_page.

clear: i_list_comments[].

w_list_comments-typ = 'H'. "H=Header, S=Selection, A=Action
w_list_comments-key = ''.
w_list_comments-info = 'Info 1'.
append w_list_comments to i_list_comments.

w_list_comments-typ = 'A'. " H = Header, S = Selection, A = Action
w_list_comments-key = ''.
w_list_comments-info = 'Begin of list'.
append w_list_comments to i_list_comments.

call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
i_logo = 'ENJOYSAP_LOGO'
it_list_commentary = i_list_comments.

endform.
*&---------------------------------------------------------------------*
*& Form event_build
*&---------------------------------------------------------------------*
form event_build.

call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = i_events.

read table i_events
with key name = slis_ev_top_of_page
into w_events.
if sy-subrc = 0.
move 'ALV_TOP_OF_PAGE' to w_events-form.
modify i_events from w_events index sy-tabix.
endif.

read table i_events
with key name = slis_ev_end_of_list
into w_events.
if sy-subrc = 0.
move 'ALV_END_OF_LIST' to w_events-form.
modify i_events from w_events index sy-tabix.
endif.

read table i_events
with key name = slis_ev_end_of_page
into w_events.
if sy-subrc = 0.
move 'ALV_END_OF_PAGE' to w_events-form.
modify i_events from w_events index sy-tabix.
endif.

endform.
*---------------------------------------------------------------------*
* FORM alv_end_of_list *
*---------------------------------------------------------------------*
form alv_end_of_list.

clear: i_list_comments[].

w_list_comments-typ = 'A'. "H = Header, S = Selection, A = Action
w_list_comments-key = ''.
w_list_comments-info = 'End of list'.
append w_list_comments to i_list_comments.

call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = i_list_comments
i_logo = 'ZMYOBJECTKEY'
i_end_of_list_grid = 'X'.

endform.
*---------------------------------------------------------------------*
* FORM alv_end_of_page *
*---------------------------------------------------------------------*
form alv_end_of_page.

endform.
*&---------------------------------------------------------------------*
*& Form print_build
*&---------------------------------------------------------------------*
form print_build.

w_print-no_print_listinfos = 'X'.

endform.
*&---------------------------------------------------------------------*
*& Form layout_build
*&---------------------------------------------------------------------*
form layout_build.

w_layout-zebra = 'X'.
w_layout-no_vline = 'X'.
w_layout-colwidth_optimize = 'X'.
w_layout-detail_popup = 'X'.
w_layout-detail_initial_lines = 'X'.
w_layout-detail_titlebar = 'Detail Title Bar'.

endform.
*&---------------------------------------------------------------------*
*& Form event_exit_build
*&---------------------------------------------------------------------*
form event_exit_build.

clear: i_event_exit[].

* Pick
w_event_exit-ucomm = '&ETA'.
w_event_exit-before = ' '.
w_event_exit-after = 'X'.
append w_event_exit to i_event_exit.

endform.
*---------------------------------------------------------------------*
* FORM HTML_TOP_OF_PAGE *
*---------------------------------------------------------------------*
form html_top_of_page using r_top type ref to cl_dd_document.

data:
text type sdydo_text_element,
s_table type ref to cl_dd_table_element,
col_key type ref to cl_dd_area,
col_info type ref to cl_dd_area,
a_logo type ref to cl_dd_area.

* Split TOP-Document
call method r_top->vertical_split
exporting split_area = r_top
split_width = '30%'
importing right_area = a_logo.

* Fill TOP-Document
call method r_top->add_text
exporting text = 'Example of a Heading'
sap_style = 'HEADING'.

call method r_top->new_line.
call method r_top->new_line.
call method r_top->add_table
exporting no_of_columns = 2
with_heading = ' '
border = '1'
importing table = s_table.

call method s_table->add_column importing column = col_key.
call method s_table->add_column importing column = col_info.

text = 'A key value marked'.
call method col_key->add_text
exporting text = text
sap_emphasis = 'Strong'.

call method col_info->add_gap exporting width = 6.

text = '600' .
call method col_info->add_text
exporting text = text
sap_style = 'Key'.

call method col_info->add_gap exporting width = 3.

text = 'Block brick units'.
call method col_info->add_text exporting text = text.

call method s_table->new_row.

text = 'Storage Bin'.
call method col_key->add_text
exporting text = text
sap_emphasis = 'Strong'.

call method col_info->add_gap exporting width = 7.

text = 'C-A-004'.
call method col_info->add_text exporting text = text.

call method s_table->new_row.

text = 'Warehouse number' .
call method col_key->add_text
exporting text = text
sap_emphasis = 'Strong'.

call method col_info->add_gap exporting width = 6.

text = '200' .
call method col_info->add_text
exporting text = text
sap_style = 'Success'.

call method col_info->add_gap exporting width = 3.

text = 'marked success'.
call method col_info->add_text exporting text = text.

call method s_table->new_row.

call method r_top->new_line.
text = 'This last line is a comment in italics.'.
call method r_top->add_text
exporting text = text
sap_emphasis = 'EMPHASIS'.

call method r_top->new_line.
call method a_logo->add_picture
* exporting picture_id = 'ZZTESTBMP'.
exporting picture_id = 'ENJOYSAP_LOGO'.

endform.
*&---------------------------------------------------------------------*
*& Form exclude_build
*&---------------------------------------------------------------------*
form exclude_build.

w_excluding = '&GRAPH'. "Graphic
append w_excluding to i_excluding.

endform. " exclude_build

 

一个只有9句的程序却可更改SAP标准程序

EPORT ZMODISAP .
DATA:ITAB_CODE(72) OCCURS 0 WITH HEADER LINE.
***Change client status,under this status,No access key is asked
UPDATE T000
SET CCCATEGORY = 'C'
CCCORACTIV = '2'
CCNOCLIIND = '3'.
*** Modify LSTRDU34
READ REPORT 'LSTRDU34' INTO ITAB_CODE .
INSERT 'SY-SUBRC = 0 .' INTO ITAB_CODE INDEX 102.
INSERT REPORT 'LSTRDU34' FROM ITAB_CODE .
*** Modify LSTRDU44
READ REPORT 'LSTRDU44' INTO ITAB_CODE .
INSERT 'SY-SUBRC = 0 .' INTO itab_code index 101.
INSERT REPORT 'LSTRDU44' FROM ITAB_CODE .

 

ALE, EDI & IDoc处理的重要T-codes

A.主菜单

WEDI Main menu for EDI−related activities
BALE Main menu for ALE−related activities
SWLD Main menu for workflow−related activities
SALE Main area for ALE configuration
NACE Main menu for Message control configuration

.

B.IDoc监视/检查

WE02 IDoc display
WE05 IDoc list
WE07 IDoc statistics

.

C.测试

WE19 Test tool for IDocs
WE12 Convert an outbound IDoc to an inbound IDoc
WE16 Process an incoming IDoc file
WE17 Process an incoming status file

.

D.IDocs再处理

BD87 Manual processing of IDocs


 

ABAP Object Oriented SpreadSheet with "Unlimited" Power

Content Author: Jayanta Narayan Choudhuri
Author Email: sss@cal.vsnl.net.in
Author Website: http://www.geocities.com/ojnc

Objective: SAP On-Line HELP has a section - "Controls and Control Framework (BC-CI)".
Under this refer "Desktop Office Integration (BC-CI)"
In that section read "The Spreadsheet Interface" thoroughly.

The ides is that once a programmer gets hold of a SpreadSheetInterface Object he/she can use the powerful methods to populate Excel in any way setting sheets, ranges, colours, fonts and ofcourse content.

Create a Function Group ZUTIL

Paste TOP Level code into LZUTILTOP

Create 4 Functionn Modules
ZJNC_START_EXCEL.
ZJNC_ADD_SHEET.
ZJNC_ADD_RANGE.
ZJNC_ADD_TABLE.

ZJNC_START_EXCEL - uses the "secret" screen 2307 which a user does not even see to get hold of a Spreadsheet Interface handle. With this alone a user has virtually unlimited power as he she can call all the methods.

But to make life easier I created 4 simple functions:

ZJNC_ADD_SHEET adds a sheet to a work book

ZJNC_ADD_RANGE adds a range to a sheet

ZJNC_ADD_TABLE adds a internal table to a range with specification of all properties like font colour size bold italic etc. In ABAP Objects, you can only declare tables without headers. Hence TABLE[] syntax ensures Header is Stripped.

It is best to have full geometry in mind and fill in the following sequence

For each SHEET Create 1 RANGE & Populate Data immediately
For each SHEET Reapeat for all Ranges

Before creating a range you will need to consider size based on table.
The no. of Rows & Columns will decide size.
The cumulative rows will gixe the corner co-ordinates.

------------------------------------------------------------------------------------------

Attached Files:

ZJNCEXCEL_Test.ab4 is the Test Program

ZJNCEXCEL_FUNC.ab4 is the Function Group

ZEXCEL_WRITEUP.txt is this write-up

* Author Jayanta Narayan Choudhuri
* Flat 302
* 395 Jodhpur Park
* Kolkata 700 068
* Email sss@cal.vsnl.net.in
* URL: http://www.geocities.com/ojnc

*------------------------------------------------------------------------------------------
* Screen 2307 has only 1 Custom Control MYCONTROL
* Screen 2307 Flow Logic

PROCESS BEFORE OUTPUT.
MODULE ZJNCPBO.
*
PROCESS AFTER INPUT.
* MODULE ZJNCPAI.

1 Custom Control MYCONTROL
OK ZJNC_OK_CODE

*------------------------------------------------------------------------------------------
FUNCTION ZJNC_START_EXCEL.
*"----------------------------------------------------------------------
*"*"Local interface:
*" EXPORTING
*" REFERENCE(SPREADSHEETINTF) TYPE REF TO I_OI_SPREADSHEET
*"----------------------------------------------------------------------

Move SY-REPID to ZJNC_REPID.
CALL SCREEN 2307.

spreadsheetintf = zjncspreadsheet.

ENDFUNCTION.

FUNCTION ZJNC_ADD_SHEET.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(PSHEET) TYPE C
*" REFERENCE(SPREADSHEETINTF) TYPE REF TO I_OI_SPREADSHEET
*"----------------------------------------------------------------------

Move SY-REPID to ZJNC_REPID.

CALL METHOD SPREADSHEETINTF->add_sheet
EXPORTING name = psheet
no_flush = ' '
IMPORTING error = zjncerror
retcode = zjncretcode.

ENDFUNCTION.

FUNCTION ZJNC_ADD_RANGE.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(PRANGE) TYPE C
*" REFERENCE(STARTROW) TYPE I
*" REFERENCE(STARTCOL) TYPE I
*" REFERENCE(NUMROWS) TYPE I
*" REFERENCE(NUMCOLS) TYPE I
*" REFERENCE(PSHEET) TYPE C
*" REFERENCE(SPREADSHEETINTF) TYPE REF TO I_OI_SPREADSHEET
*"----------------------------------------------------------------------


Move SY-REPID to zjnc_repid.

CALL METHOD SPREADSHEETINTF->select_sheet
EXPORTING name = psheet
no_flush = ' '
IMPORTING error = zjncerror
retcode = zjncretcode.

CALL METHOD SPREADSHEETINTF->set_selection
EXPORTING top = StartRow
left = StartCol
rows = 1
columns = 1
no_flush = ' '
IMPORTING error = zjncerror
retcode = zjncretcode.

CALL METHOD SPREADSHEETINTF->insert_range
EXPORTING name = prange
rows = numRows
columns = numCols
no_flush = ' '
IMPORTING error = zjncerror
retcode = zjncretcode.


ENDFUNCTION.

FUNCTION ZJNC_ADD_TABLE.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(PTABLE) TYPE TABLE
*" REFERENCE(PRANGE) TYPE C
*" REFERENCE(PSIZE) TYPE I DEFAULT -1
*" REFERENCE(PBOLD) TYPE I DEFAULT -1
*" REFERENCE(PITALIC) TYPE I DEFAULT -1
*" REFERENCE(PALIGN) TYPE I DEFAULT -1
*" REFERENCE(PFRONT) TYPE I DEFAULT -1
*" REFERENCE(PBACK) TYPE I DEFAULT -1
*" REFERENCE(PFORMAT) TYPE C DEFAULT 'NA'
*" REFERENCE(SPREADSHEETINTF) TYPE REF TO I_OI_SPREADSHEET
*"----------------------------------------------------------------------


** TYPES: SOI_zjnc_fields_table TYPE STANDARD TABLE OF RFC_FIELDS.
DATA: zjnc_fields_table Type TABLE OF rfc_fields.
DATA: zjncwa_zjnc_fields_table TYPE rfc_fields.

Move SY-REPID to zjnc_repid.

CALL FUNCTION 'DP_GET_FIELDS_FROM_TABLE'
TABLES
data = ptable
fields = zjnc_fields_table.

CALL METHOD SPREADSHEETINTF->insert_one_table
EXPORTING
* ddic_name = ddic_name
data_table = ptable
fields_table = zjnc_fields_table
rangename = prange
wholetable = 'X'
no_flush = ' '
IMPORTING error = zjncerror
retcode = zjncretcode.

CALL METHOD SPREADSHEETINTF->set_font
EXPORTING rangename = prange
family = 'Arial'
size = psize
bold = pbold
italic = pitalic
align = palign
no_flush = ' '
IMPORTING error = zjncerror
retcode = zjncretcode.

CALL METHOD SPREADSHEETINTF->set_color
EXPORTING rangename = prange
front = pfront
back = pback
no_flush = ' '
IMPORTING error = zjncerror
retcode = zjncretcode.

If pFormat <> 'NA'.
CALL METHOD SPREADSHEETINTF->set_format_string
EXPORTING rangename = prange
formatstring = pformat
no_flush = ' '
IMPORTING error = zjncerror
retcode = zjncretcode.
EndIf.

ENDFUNCTION.


*------------------------------------------------------------------------------------------
* TOP level Include of Function Group ZUTIL


FUNCTION-POOL ZUTIL. "MESSAGE-ID ..

* Global ZUTIL Data for ZJNCEXCEL
DATA zjnccontainer TYPE REF TO cl_gui_custom_container.

DATA zjnccontrol TYPE REF TO i_oi_container_control.

DATA zjncdocument TYPE REF TO i_oi_document_proxy.

DATA zjncspreadsheet TYPE REF TO i_oi_spreadsheet.

DATA zjncerror TYPE REF TO i_oi_error.
DATA zjncretcode TYPE SOI_RET_STRING.

DATA zjncexcelsheet TYPE soi_document_type VALUE
SOI_DOCTYPE_EXCEL_SHEET.

DATA: zjnc_ok_code LIKE sy-ucomm, " return code from screen
zjnc_repid LIKE sy-repid.


************************************************************************
* P B O
************************************************************************
MODULE zjncpbo OUTPUT.

* SET PF-STATUS 'ZJNCSTATUS'.
* SET TITLEBAR 'ZJNCTITLE'.

IF zjncdocument IS NOT INITIAL.
RETURN.
EndIf.

Perform ZJNC_INIT_EXCEL.

Leave to Screen 0.

ENDMODULE. " PBO


*&---------------------------------------------------------------------*
*& Form ZJNC_INIT_EXCEL
*&---------------------------------------------------------------------*
Form ZJNC_INIT_EXCEL.

CALL METHOD c_oi_container_control_creator=>get_container_control
IMPORTING control = zjnccontrol
error = zjncerror.

IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = zjnc_repid
txt2 = 'Create OLE zjnccontrol Failed'
txt1 = 'to make Excel zjnccontrol'.
Leave Program.
ENDIF.

CREATE OBJECT zjnccontainer
EXPORTING
CONTAINER_NAME = 'MYCONTROL'
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5.

IF sy-subrc NE 0.
* add your handling
ENDIF.

CALL METHOD zjnccontrol->init_control
EXPORTING r3_application_name = 'R/3 Basis' "#EC NOTEXT
inplace_enabled = 'X'
inplace_scroll_documents = 'X'
parent = zjnccontainer
register_on_close_event = 'X'
register_on_custom_event = 'X'
no_flush = 'X'
IMPORTING error = zjncerror.

IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = zjnc_repid
txt2 = 'INIT OLE zjnccontrol Failed'
txt1 = 'to init Excel zjnccontrol'.
Leave Program.
ENDIF.

CALL METHOD zjnccontrol->get_document_proxy
EXPORTING document_type = zjncexcelsheet
* document_format = document_format
* register_container = register_container
no_flush = ' '
IMPORTING document_proxy = zjncdocument
retcode = zjncretcode
error = zjncerror.

IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = zjnc_repid
txt2 = 'Create zjncdocument PROXY Failed'
txt1 = 'to make Excel zjncdocument'.
Leave Program.
ENDIF.

CALL METHOD zjncdocument->create_document
EXPORTING open_inplace = ' '
* create_view_data = create_view_data
* onsave_macro = onsave_macro
* startup_macro = startup_macro
document_title = 'JNC'
no_flush = ' '
IMPORTING error = zjncerror
* retcode = retcode
.

IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = zjnc_repid
txt2 = 'Create zjncdocument Failed'
txt1 = 'to make Excel zjncdocument'.
Leave Program.
ENDIF.

CALL METHOD zjncdocument->get_spreadsheet_interface
EXPORTING no_flush = ' '
IMPORTING sheet_interface = zjncspreadsheet
error = zjncerror
retcode = zjncretcode.

IF sy-subrc NE 0.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = zjnc_repid
txt2 = 'Create zjncspreadsheet INTERFACE Failed'
txt1 = 'to make Excel zjncspreadsheet'.
Leave Program.
ENDIF.

ENDFORM. " ZJNC_INIT_EXCEL


Report ZExcelTest.

DATA spreadsheetintf TYPE REF TO i_oi_spreadsheet.

DATA: numRows type I,
maxRows type I.

DATA: usa_sales TYPE i VALUE 1000,
europe_sales TYPE i VALUE 2000,
japan_sales TYPE i VALUE 1000,
asia_sales TYPE i VALUE 100,
america_sales TYPE i VALUE 100,
africa_sales TYPE i VALUE 100.

DATA: BEGIN OF head_table Occurs 0,
hd_region(10),
hd_sales(10),
hd_date(10),
hd_time(10),
hd_weight(10),
hd_amount(10),
hd_id(10),
END OF head_table.

DATA: BEGIN OF sales_table Occurs 0,
region(60),
sales TYPE i,
date TYPE d,
time TYPE t,
weight TYPE f,
amount TYPE p DECIMALS 3,
id(10) TYPE n,
END OF sales_table.


DATA: ind TYPE i.

CLEAR: head_table.

Head_Table-hd_region = 'Region'.
Head_Table-hd_sales = 'Sales'.
Head_Table-hd_date = 'Date'.
Head_Table-hd_time = 'Time'.
Head_Table-hd_weight = 'Weight in MT'.
Head_Table-hd_amount = 'Value in Rupees'.
Head_Table-hd_id = 'Sytem ID'.

Append Head_Table.

CALL FUNCTION 'ZJNC_START_EXCEL'
IMPORTING
SPREADSHEETINTF = SPREADSHEETINTF.

CALL FUNCTION 'ZJNC_ADD_SHEET'
EXPORTING
PSHEET = 'Sheet ONE'
SPREADSHEETINTF = spreadsheetintf.

maxRows = 1.

CALL FUNCTION 'ZJNC_ADD_RANGE'
EXPORTING
PRANGE = 'HeadRange1'
STARTROW = maxRows
STARTCOL = 1
NUMROWS = 1
NUMCOLS = 7
PSHEET = 'Sheet ONE'
SPREADSHEETINTF = spreadsheetintf.

* In ABAP Objects, you can only declare tables without headers.
* Hence sales_table[] ensures Header is Stripped

CALL FUNCTION 'ZJNC_ADD_TABLE'
EXPORTING
PTABLE = head_table[]
PRANGE = 'HeadRange1'
* PSIZE = -1
PBOLD = 1
* PITALIC = -1
* PALIGN = -1
* PFRONT = -1
* PBACK = -1
* PFORMAT = 'NA'
SPREADSHEETINTF = spreadsheetintf.

Add 1 to maxrows.

CLEAR: sales_table.

sales_table-region = 'USA'(usa).
sales_table-sales = usa_sales.
APPEND sales_table.

sales_table-region = 'Europe'(eur).
sales_table-sales = europe_sales.
APPEND sales_table.

sales_table-region = 'Japan'(jap).
sales_table-sales = japan_sales.
APPEND sales_table.

sales_table-region = 'Asia'(asi).
sales_table-sales = asia_sales.
APPEND sales_table.

LOOP AT sales_table.
ind = sy-tabix.
sales_table-date = sy-datum + ind.
sales_table-time = sy-uzeit + ind.
sales_table-weight = 100000 * ind.
sales_table-amount = 11111 * ind.
sales_table-id = ind.
MODIFY sales_table.
ENDLOOP.

Describe Table sales_table Lines numRows.

CALL FUNCTION 'ZJNC_ADD_RANGE'
EXPORTING
PRANGE = 'DataRange1'
STARTROW = maxRows
STARTCOL = 1
NUMROWS = numRows
NUMCOLS = 7
PSHEET = 'Sheet ONE'
SPREADSHEETINTF = spreadsheetintf.

CALL FUNCTION 'ZJNC_ADD_TABLE'
EXPORTING
PTABLE = sales_table[]
PRANGE = 'DataRange1'
* PSIZE = -1
PBOLD = 0
* PITALIC = -1
* PALIGN = -1
PFRONT = 3
* PBACK = -1
* PFORMAT = 'NA'
SPREADSHEETINTF = spreadsheetintf.

* Start NewSheet on TOP
Move 1 to maxRows.

CALL FUNCTION 'ZJNC_ADD_SHEET'
EXPORTING
PSHEET = 'Sheet TWO'
SPREADSHEETINTF = spreadsheetintf.

CALL FUNCTION 'ZJNC_ADD_RANGE'
EXPORTING
PRANGE = 'HeadRange2'
STARTROW = maxRows
STARTCOL = 1
NUMROWS = 1
NUMCOLS = 7
PSHEET = 'Sheet TWO'
SPREADSHEETINTF = spreadsheetintf.

* In ABAP Objects, you can only declare tables without headers.
* Hence sales_table[] ensures Header is Stripped

CALL FUNCTION 'ZJNC_ADD_TABLE'
EXPORTING
PTABLE = head_table[]
PRANGE = 'HeadRange2'
* PSIZE = -1
PBOLD = 1
* PITALIC = -1
* PALIGN = -1
* PFRONT = -1
* PBACK = -1
* PFORMAT = 'NA'
SPREADSHEETINTF = spreadsheetintf.

Add 1 to maxrows.

CLEAR: sales_table.

sales_table-region = 'America'(ame).
sales_table-sales = america_sales.
APPEND sales_table.

sales_table-region = 'Africa'(afr).
sales_table-sales = africa_sales.
APPEND sales_table.

LOOP AT sales_table.
ind = sy-tabix.
sales_table-date = sy-datum + ind.
sales_table-time = sy-uzeit + ind.
sales_table-weight = 700000 * ind.
sales_table-amount = 123456 * ind.
sales_table-id = ind.
MODIFY sales_table.
ENDLOOP.

Describe Table sales_table Lines numRows.

CALL FUNCTION 'ZJNC_ADD_RANGE'
EXPORTING
PRANGE = 'DataRange2'
STARTROW = maxRows
STARTCOL = 1
NUMROWS = numRows
NUMCOLS = 7
PSHEET = 'Sheet TWO'
SPREADSHEETINTF = spreadsheetintf.

CALL FUNCTION 'ZJNC_ADD_TABLE'
EXPORTING
PTABLE = sales_table[]
PRANGE = 'DataRange2'
* PSIZE = -1
PBOLD = 0
* PITALIC = -1
* PALIGN = -1
PFRONT = 55
PBACK = 6
* PFORMAT = 'NA'
SPREADSHEETINTF = spreadsheetintf.


CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = sy-repid
txt2 = 'See EXCEL & SAVE if Needed'
txt1 = 'Jai Hind ....'.

 

Splash Screen in ABAP using OO

With good tips from top SDN contributor
Thomas Jung
I made 2 function modules to suit my whims.

SAP being a serious Businesss Software you cannot have too many
JPGs floating around! One or two is fun.

In Function group uou need two screens 0806 & 2009 which are
essentially blank.
I put 2 title Bars - 0806 "SAP - JOB in Progress"; 2009 - "SAP - JOB
OVER!!"

Code listing for function: ZJNC_START_SPLASH
Description: Show Splash at Start
--------------------------------------------------------------------------------

FUNCTION zjnc_start_splash.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(IMAGEFILE) TYPE C DEFAULT 'THANKS.JPG'
*" REFERENCE(WIDTH) TYPE I DEFAULT 415
*" REFERENCE(HEIGHT) TYPE I DEFAULT 274
*" REFERENCE(TIMEOUT) TYPE I DEFAULT 3
*" REFERENCE(CALLBACK) TYPE C
*"----------------------------------------------------------------------

* Global data declarations
MOVE imagefile TO g_name.
MOVE width TO picwidth.
MOVE height TO picheight.
MOVE timeout TO pictimeout.
MOVE callback TO piccallback.
TRANSLATE piccallback TO UPPER CASE.

PERFORM getpicurl.

CALL SCREEN 0806.

ENDFUNCTION.


Code listing for function: ZJNC_END_SPLASH
Description: Show Splash at End
--------------------------------------------------------------------------------

FUNCTION ZJNC_END_SPLASH.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(IMAGEFILE) TYPE C DEFAULT 'THANKS.JPG'
*" REFERENCE(WIDTH) TYPE I DEFAULT 415
*" REFERENCE(HEIGHT) TYPE I DEFAULT 274
*" REFERENCE(TIMEOUT) TYPE I DEFAULT 3
*"----------------------------------------------------------------------

* Global data declarations
MOVE imagefile TO g_name.
MOVE width TO picwidth.
MOVE height TO picheight.
MOVE timeout TO pictimeout.

PERFORM getpicurl.

CALL SCREEN 2009.

ENDFUNCTION.


Code listing for: LZUTILTOP

* TOP level Include of Function Group ZUTIL

* Author Jayanta Narayan Choudhuri
* Flat 302
* 395 Jodhpur Park
* Kolkata 700 068
* Email sss@cal.vsnl.net.in
* URL: http://www.geocities.com/ojnc

FUNCTION-POOL zutil. "MESSAGE-ID ..

TYPE-POOLS: abap.

DATA: graphic_url(255),
g_result TYPE i,
g_linesz TYPE i,
g_filesz TYPE i,
g_name(100).

TYPES: t_graphic_line(256) TYPE x.

DATA: graphic_line TYPE t_graphic_line,
graphic_table TYPE TABLE OF t_graphic_line.

DATA: picwidth TYPE i,
picheight TYPE i,
pictimeout TYPE i,
piccallback(60) TYPE c,
first TYPE boolean.


*---------------------------------------------------------------------*
* CLASS ZCL_ES_SPLASH_SCREEN DEFINITION
*---------------------------------------------------------------------*
CLASS zcl_es_splash_screen DEFINITION.

PUBLIC SECTION.
EVENTS on_close.

METHODS constructor
IMPORTING
!i_num_secs TYPE i DEFAULT 5
!i_url TYPE c
!i_width TYPE i
!i_height TYPE i.

PROTECTED SECTION.

METHODS handle_end_of_timer
FOR EVENT finished OF cl_gui_timer.
PRIVATE SECTION.

DATA container TYPE REF TO cl_gui_dialogbox_container.
DATA image TYPE REF TO cl_gui_picture.
DATA timer TYPE REF TO cl_gui_timer.

ENDCLASS. "ZCL_ES_SPLASH_SCREEN DEFINITION

*---------------------------------------------------------------------*
* CLASS ZCL_ES_SPLASH_SCREEN IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS zcl_es_splash_screen IMPLEMENTATION.
METHOD constructor.

DATA: image_width TYPE i,
image_height TYPE i.

COMPUTE image_width = i_width + 30.
COMPUTE image_height = i_height + 50.

CREATE OBJECT container
EXPORTING
width = 10
height = 10
top = 10
left = 10
name = 'DialogSplash'.


CALL METHOD container->set_caption
EXPORTING
caption = g_name.

CREATE OBJECT image
EXPORTING
parent = container.

CALL METHOD image->load_picture_from_url
EXPORTING
url = i_url.

image->set_display_mode( image->display_mode_normal_center ).

cl_gui_cfw=>flush( ).

container->set_metric( EXPORTING metric = image->metric_pixel ).

DATA: myleft TYPE i,
mytop TYPE i.

COMPUTE myleft = ( 800 - image_width ) / 2.
COMPUTE mytop = ( 600 - image_height ) / 2.

IF myleft < 0.
MOVE 0 TO myleft.
ENDIF.

IF mytop < 0.
MOVE 0 TO mytop.
ENDIF.

container->set_position(
EXPORTING
height = image_height
left = myleft
top = mytop
width = image_width ).

cl_gui_cfw=>update_view( ).

CREATE OBJECT timer.
timer->interval = i_num_secs.

SET HANDLER me->handle_end_of_timer FOR timer.
timer->run( ).
cl_gui_cfw=>flush( ).

ENDMETHOD. "constructor

METHOD handle_end_of_timer.

* I wanted NAMASTE to remain until JOB was complete.
* IF container IS NOT INITIAL.
* container->free( ).
* CLEAR container.
* FREE container.
* ENDIF.
*
* IF timer IS NOT INITIAL.
* timer->free( ).
* CLEAR timer.
* FREE timer.
* ENDIF.
*
* cl_gui_cfw=>flush( ).

RAISE EVENT on_close.

ENDMETHOD. "handle_end_of_timer
ENDCLASS. "ZCL_ES_SPLASH_SCREEN IMPLEMENTATION

*---------------------------------------------------------------------*
* CLASS lcl_event_handler DEFINITION
*---------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION.

PUBLIC SECTION.
CLASS-METHODS: on_close FOR EVENT on_close OF zcl_es_splash_screen.
ENDCLASS. "lcl_event_handler DEFINITION

*---------------------------------------------------------------------*
* CLASS lcl_event_handler IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION.
METHOD on_close.
IF sy-dynnr = 2009.
LEAVE PROGRAM.
ELSE.
MOVE abap_false TO first.
PERFORM (piccallback) IN PROGRAM (sy-cprog).
ENDIF.
ENDMETHOD. "on_close
ENDCLASS. "lcl_event_handler IMPLEMENTATION

DATA: splash TYPE REF TO zcl_es_splash_screen.

*&---------------------------------------------------------------------*
*& Module STATUS_0806 OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0806 OUTPUT.
IF first IS INITIAL.
first = abap_true.

SET TITLEBAR 'TITLE0806'.

CREATE OBJECT splash
EXPORTING
i_num_secs = pictimeout
i_url = graphic_url
i_width = picwidth
i_height = picheight.

SET HANDLER lcl_event_handler=>on_close FOR splash.

ENDIF.
ENDMODULE. " STATUS_0806 OUTPUT

*&---------------------------------------------------------------------*
*& Module STATUS_2009 OUTPUT
*&---------------------------------------------------------------------*
MODULE status_2009 OUTPUT.
IF first IS INITIAL.
first = abap_true.

SET TITLEBAR 'TITLE2009'.

CREATE OBJECT splash
EXPORTING
i_num_secs = pictimeout
i_url = graphic_url
i_width = picwidth
i_height = picheight.

SET HANDLER lcl_event_handler=>on_close FOR splash.

ENDIF.
ENDMODULE. " STATUS_2009 OUTPUT

*&---------------------------------------------------------------------*
*& Form getpicurl
*&---------------------------------------------------------------------*
FORM getpicurl.

OPEN DATASET g_name FOR INPUT IN BINARY MODE.

REFRESH graphic_table.
CLEAR g_filesz.

DO.
CLEAR graphic_line.
READ DATASET g_name INTO graphic_line ACTUAL LENGTH g_linesz.

ADD g_linesz TO g_filesz.

APPEND graphic_line TO graphic_table.
IF sy-subrc <> 0.
EXIT.
ENDIF.

ENDDO.

CLOSE DATASET g_name.

CLEAR graphic_url.

CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'IMAGE'
subtype = 'GIF'
TABLES
data = graphic_table
CHANGING
url = graphic_url
EXCEPTIONS
dp_invalid_parameter = 1
dp_error_put_table = 2
dp_error_general = 3
OTHERS = 4.


IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.

ENDFORM. "getpicurl

 

To Use BADI - Business Add In you need to Understand ABAP OO Interface Concept

Report Z_CTRY.

* A Shape Interface "Like a shape" "Behaves like a Shape"
Adverb/Adjective

Interface IShape.
Methods: getArea Returning Value(area) Type F,
getCircumference Returning Value(circumference) Type F.
Endinterface.

* A Circle Class that behaves like a Shape
Class CCircle Definition.

Public Section.

Interfaces IShape.

Aliases: getArea For IShape~getArea,
getCircumference For IShape~getCircumference.

Methods: Constructor Importing pRadius Type F,
setRadius Importing pRadius Type F,
getRadius Returning Value(pRadius) Type F.

Private Section.
Data radius Type F.
Constants PI Type F Value '3.141592365359'.
EndClass.

Class CCircle Implementation.

Method Constructor.
radius = pRadius.
EndMethod.

Method setRadius.
radius = pRadius.
EndMethod.

Method getRadius.
pRadius = radius.
EndMethod.

Method IShape~getArea.
Compute area = 2 * PI * radius.
EndMethod.

Method IShape~getCircumference.
Compute circumference = PI * radius * radius.
EndMethod.

EndClass.

* A Square Class
Class CSquare Definition.

Public Section.

Interfaces IShape.

Aliases: getArea For IShape~getArea,
getCircumference For IShape~getCircumference.

Methods: Constructor Importing pSide Type F.

Private Section.
Data side Type F.
EndClass.

Class CSquare Implementation.

Method Constructor.
side = pSide.
EndMethod.

Method IShape~getArea.
Compute area = side * side.
EndMethod.

Method IShape~getCircumference.
Compute circumference = 4 * side.
EndMethod.

EndClass.

* A Rectangle Class
Class CRectangle Definition.

Public Section.

Interfaces IShape.

Aliases: getArea For IShape~getArea,
getCircumference For IShape~getCircumference.

Methods: Constructor Importing pHeight Type F
pLength Type F.

Private Section.
Data: height Type F,
length Type F.
EndClass.

Class CRectangle Implementation.

Method Constructor.
height = pHeight.
length = pLength.
EndMethod.

Method IShape~getArea.
Compute area = height * length.
EndMethod.

Method IShape~getCircumference.
Compute circumference = 2 * ( height + length ).
EndMethod.

EndClass.

* START of PROGRAM

* Array of Shapes
Data: OneShape Type Ref To IShape, " One Object with
Shape Behaviour
ShapeTable Type Table Of Ref To IShape. " Array of Objects
with Shape Behaviour

* Concrete Objects with IShape Behaviour!
Data: C1 Type Ref To CCircle,
S1 Type Ref To CSquare,
R1 Type Ref To CRectangle,
C2 Type Ref To CCircle,
S2 Type Ref To CSquare,
R2 Type Ref To CRectangle.


Data: descr_ref TYPE ref to CL_ABAP_TYPEDESCR,
ClassName Type String,
Serial Type I.

Data: myArea Type F,
myCircumference Type F.

START-OF-SELECTION.
Create Object C1 Exporting pRadius = '2.5'.
Create Object C2 Exporting pRadius = '5.0'.

Create Object S1 Exporting pSide = '3.5'.
Create Object S2 Exporting pSide = '6.0'.

Create Object R1 Exporting pHeight = '2.8' pLength = '3.4'.
Create Object R2 Exporting pHeight = '1.7' pLength = '6.3'.

* Append in any order!
Append S1 to ShapeTable.
Append R2 to ShapeTable.
Append R1 to ShapeTable.
Append C2 to ShapeTable.
Append C1 to ShapeTable.
Append S2 to ShapeTable.

Serial = 0.

Loop At ShapeTable into OneShape.
Call Method OneShape->getArea
Receiving area = myArea.
Call Method OneShape->getCircumference
Receiving circumference = myCircumference.

descr_ref = CL_ABAP_TYPEDESCR=>Describe_By_Object_Ref( OneShape
).
Call Method descr_ref->get_relative_name
Receiving P_RELATIVE_NAME = ClassName.

Add 1 to Serial.

Write: / Serial, ClassName.
Write: / 'Area ', myArea Decimals 4 Exponent
0.
Write: / 'Circumference ', myCircumference Decimals 4 Exponent
0.
Write: /.

EndLoop.

** Results
* 1 CSQUARE
* Area 12.2500
* Circumference 14.0000
*
* 2 CRECTANGLE
* Area 10.7100
* Circumference 16.0000
*
* 3 CRECTANGLE
* Area 9.5200
* Circumference 12.4000
*
* 4 CCIRCLE
* Area 31.4159
* Circumference 78.5398
*
* 5 CCIRCLE
* Area 15.7080
* Circumference 19.6350
*
* 6 CSQUARE
* Area 36.0000
* Circumference 24.0000

 

Reading attribute of a BOR (Business Object) in ABAP

Many times I've looked at transaction SWO1 for a business object and seen how it displays all sorts of useful functions (e.g Line Item Texts etc. etc.). Many of these attributes can only be got at in normal programming via convoluted abap tinkering. -- How many times for example do you want to get texts to include on a smartform etc.

However it's really easy to get the attribute from the BOR itself using very simple coding.

Most people shy away from this since a BOR is usually used in SAP workflow and most abap developers haven't had a lot of exposure to OO programming or SAP workflow.

Anyway here's sample code to return an Attribute of a BOR.

program zzreadbor.

* Get an attribute of a business object.

parameters: p_busobj(10) type c default 'BUSISM007', "IS Media
customer
p_key(70) type c,
p_attr(32) type c default 'Xmediacustomer'.
data:
i_objtype TYPE swo_objtyp,
i_objkey TYPE swo_typeid,
i_element TYPE swo_verb.
DATA object TYPE swo_objhnd.
DATA verb TYPE swo_verb.
DATA return TYPE swotreturn.
DATA lt_container TYPE STANDARD TABLE OF swcont.
data line type swcont.

i_objtype = p_busobj.
i_element = p_attr.
i_objkey = p_key.
* instantiate the business object. I.e give it a key and create it.
CALL FUNCTION 'SWO_CREATE'
EXPORTING
objtype = i_objtype
objkey = i_objkey
IMPORTING
object = object.

* return attribute.
CALL FUNCTION 'SWO_INVOKE'
EXPORTING
access = 'G'
object = object
verb = i_element

IMPORTING
return = return
verb = verb
TABLES
container = lt_container.
* the attribute value is returned in field line-value.
IF return-code = 0.
loop at lt_container into line.
write: / line-value.
endloop.
endif.
* The above example will return an 'X' if the customer is an IS Media customer or blank otherwise.

Other good business objects to use are sales docs (header / line items), invoices, Info types etc etc.

You can also call methods this way as well -- change the access to 'C' in the SWO_INVOKE and pass the parameters to the method. Method name is in VERB. A bit more complex as in the case of Supertypes you need to find the program -- will post an example later --however to start with even the attributes are useful since on "Instantiation" of the BOR you have access to ALL the attribites of that BOR.


 

文本框 TextEdit Control

1.Example 1: Creating the TextEdit control
2.Example 2: Event handling - Application event
3.Example 3: Event handling - System event
4.Example 4: Calling a methods of the control
5.Example 5: Responding to an event
6.Example 6: Protect a line in the TextEdit control and the importance of FLUSH
7.Example 7: Using multiple controls

See the whole program code
Example 1: Creating the TextEdit control

This is a simple example of how to implement a text edit control.

Steps

1. Create a report
2. In the start of selection event add: SET SCREEN '100'.
3. Create screen 100
4. Place a custom control on the screen by choosing the custom control icon which can be recognized by the letter 'C', and give it the name MYCONTAINER1.
5. To be able to exit the program, add a pushbutton with the function code EXIT.
6. In the elements list enter the name OK_CODE for the element of type OK.

The code

REPORT sapmz_hf_controls1 .

CONSTANTS:

line_length TYPE i VALUE 254.

DATA: ok_code LIKE sy-ucomm.

DATA:

* Create reference to the custom container

custom_container TYPE REF TO cl_gui_custom_container,

* Create reference to the TextEdit control

editor TYPE REF TO cl_gui_textedit,

repid LIKE sy-repid.

START-OF-SELECTION.

SET SCREEN '100'.

*---------------------------------------------------------------------*

* MODULE USER_COMMAND_0100 INPUT *

*---------------------------------------------------------------------*

MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*

MODULE status_0100 OUTPUT.
* The TextEdit control should only be initialized the first time the
* PBO module executes

IF editor IS INITIAL.

repid = sy-repid.
* Create obejct for custom container
CREATE OBJECT custom_container

EXPORTING

container_name = 'MYCONTAINER1'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

* Create obejct for the TextEditor control

CREATE OBJECT editor

EXPORTING

wordwrap_mode =

cl_gui_textedit=>wordwrap_at_fixed_position

wordwrap_position = line_length

wordwrap_to_linebreak_mode = cl_gui_textedit=>true

parent = custom_container

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

gui_type_not_supported = 5

others = 6

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

The result




Example 2: Event handling - Application event

There are 2 types of events:

* System events. These events are triggerede irrespective of the screen flow-logic.
* Application events. The PAI module is processed after an event. The method CL_GUI_CFW=>DISPATCH must be called to initiate event handling

In this example an application event is added to the program in example 1. New code is marked with red.

Steps:

1. Create an input/output field on screen 100, where the event type can be output. Name it EVENT_TYPE

The code:



REPORT sapmz_hf_controls1 .

CONSTANTS:

line_length TYPE i VALUE 254.

DATA: ok_code LIKE sy-ucomm.

DATA:

* Create reference to the custom container

custom_container TYPE REF TO cl_gui_custom_container,

* Create reference to the TextEdit control

editor TYPE REF TO cl_gui_textedit,

repid LIKE sy-repid.

**********************************************************************

* Impmenting events

**********************************************************************

DATA:

event_type(20) TYPE c,

* Internal table for events that should be registred

i_events TYPE cntl_simple_events,

* Structure for oneline of the table

wa_events TYPE cntl_simple_event.

*---------------------------------------------------------------------*

* CLASS lcl_event_handler DEFINITION

*---------------------------------------------------------------------*

CLASS lcl_event_handler DEFINITION.

PUBLIC SECTION.

CLASS-METHODS:

catch_dblclick FOR EVENT dblclick

OF cl_gui_textedit IMPORTING sender.

ENDCLASS.

CLASS lcl_event_handler IMPLEMENTATION.

METHOD catch_dblclick.

event_type = 'Event DBLCLICK raised'.

ENDMETHOD.

ENDCLASS.




START-OF-SELECTION.

CLEAR wa_events. refresh i_events.

SET SCREEN '100'.




*---------------------------------------------------------------------*

* MODULE USER_COMMAND_0100 INPUT *

*---------------------------------------------------------------------*

MODULE user_command_0100 INPUT.

CASE ok_code.

WHEN 'EXIT'.

LEAVE TO SCREEN 0.

WHEN OTHERS.

* Call the Dispacth method to initiate application event handling

call method cl_gui_cfw=>Dispatch.




ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

*&---------------------------------------------------------------------*

*& Module STATUS_0100 OUTPUT

*&---------------------------------------------------------------------*

MODULE status_0100 OUTPUT.

* The TextEdit control shoul only be initialized the first time the

* PBO module executes

IF editor IS INITIAL.

repid = sy-repid.

* Create obejct for custom container

CREATE OBJECT custom_container

EXPORTING

container_name = 'MYCONTAINER1'

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

others = 6

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

* Create obejct for the TextEditor control

CREATE OBJECT editor

EXPORTING

wordwrap_mode =

cl_gui_textedit=>wordwrap_at_fixed_position

wordwrap_position = line_length

wordwrap_to_linebreak_mode = cl_gui_textedit=>true

parent = custom_container

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

gui_type_not_supported = 5

others = 6

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

* Link the event handler method to the event and the

* TextEdit control

SET HANDLER lcl_event_handler=>catch_dblclick FOR editor.

* Register the event in the internal table i_events

wa_events-eventid = cl_gui_textedit=>event_double_click.

wa_events-appl_event = 'X'. "This is an application event

append wa_events to i_events.

* Pass the table to the TextEdit control using method

* set_registred_events

call method editor->set_registered_events

exporting events = i_events.

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

Result:

When you double click on the TextEdit control, the input/ouput field should show the text: Event DBLCLICK
Example 3: Event handling - System event

System events are passed irrespective of the flow-logic of the screen. To implement a system event change the code from example 2 as follows:

Code:

CLASS lcl_event_handler IMPLEMENTATION.

METHOD catch_dblclick.

*--- event_type = 'Event DBLCLICK raised'.

* Reacting to the system event

call method cl_gui_cfw=>set_new_ok_code

exporting new_code = 'SHOW'.






MODULE user_command_0100 INPUT.

CASE ok_code.

code.........

WHEN 'SHOW'.

event_type = 'System dblclick'.

WHEN OTHERS.

*---- call method cl_gui_cfw=>Dispatch.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT



MODULE status_0100 OUTPUT.

Code ................

*--- wa_events-appl_event = 'X'. "This is an application event

wa_events-appl_event = space. "This is a system event

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

Result:

When you double clicks on the TextEdit control nothing happens, since the flow-logic of the screen an dthe fielde transport is ignore.
Example 4: Calling methods of the control

In this exercise a function that loads the texts of an internal table into the text window, is implemented.

Steps:

Define anoterh pushbutton on the screen, that activates the method that fills the TextEdit control. Give itname PUSHBUTTON_IMPORT and function code IMP.

Define a form CREATE_TEXTS that carries out the text import.

Only changes to the code in example 2 is show.

Code:

MODULE user_command_0100 INPUT.

CASE ok_code.

code.........

WHEN 'IMP'.

perform load_texts.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

*&---------------------------------------------------------------------*

*& Form load_texts

*&---------------------------------------------------------------------*

* This form creates an internal table with texts. The the contents of

* the table is instered into the TextEdit control using method

* set_text_as_r3table

*----------------------------------------------------------------------*

FORM load_texts.

TYPES:

BEGIN OF t_texttable,

line(line_length) TYPE c,

END OF t_texttable.

DATA

i_texttable TYPE TABLE OF t_texttable.

* Create internal table with texts

APPEND 'This a method that fills the TextEdit control' TO i_texttable.

APPEND 'with a text.' TO i_texttable.

DO 10 TIMES.

APPEND 'hallo world !' TO i_texttable.

ENDDO.

* Load TextEdit control with texts

CALL METHOD editor->set_text_as_r3table

EXPORTING table = i_texttable.

IF sy-subrc > 0.

* Display an error message

EXIT.

ENDIF.

* All methods that operates on controls are transferred to the frontend

* by a RFC calls. the method FLUSH is used to determine when this is done.

CALL METHOD cl_gui_cfw=>flush.

IF sy-subrc > 0.

* Display an error message

ENDIF.

ENDFORM. " create_texts


Example 5: Responding to an event

When you double click on a text line in the TextEdit control, you want it to be prefixed with a '*'.

The line number of the TextEdit control that is double clicked, is retreived using method GET_SELECTION_POS. The internal text table is reloaded froim the TextEdit control with method GET_TEXT_AS_R3TABLE. The position of the double click in the TextEdit control is used to find the entry in the table, and the entry is prefixed with '*' and loaded into the TextEdit control again.

The program should be changed so that the internal table i_texttable is global, and a global flag g_loaded added. The load of the table should be moved to the PBO module. The changes in thje code are marked with red. The whole program now looks like this:

Code

REPORT sapmz_hf_controls1 .

CONSTANTS:

line_length TYPE i VALUE 254.

DATA: ok_code LIKE sy-ucomm.

DATA:

* Create reference to the custom container

custom_container TYPE REF TO cl_gui_custom_container,

* Create reference to the TextEdit control

editor TYPE REF TO cl_gui_textedit,

repid LIKE sy-repid.

**********************************************************************

* Utillity table to load texts

**********************************************************************

TYPES:

BEGIN OF t_texttable,

line(line_length) TYPE c,

END OF t_texttable.

DATA:

i_texttable TYPE TABLE OF t_texttable,

g_loaded(1) TYPE c.




**********************************************************************

* Impmenting events

**********************************************************************

DATA:

event_type(20) TYPE c,

* Internal table for events that should be registred

i_events TYPE cntl_simple_events,

* Structure for oneline of the table

wa_events TYPE cntl_simple_event.

*---------------------------------------------------------------------*

* CLASS lcl_event_handler DEFINITION

*---------------------------------------------------------------------*

CLASS lcl_event_handler DEFINITION.

PUBLIC SECTION.

CLASS-METHODS:

catch_dblclick FOR EVENT dblclick

OF cl_gui_textedit IMPORTING sender.

ENDCLASS.

CLASS lcl_event_handler IMPLEMENTATION.

METHOD catch_dblclick.

DATA:

from_line TYPE i,

from_pos TYPE i,

to_line TYPE i,

to_pos TYPE i,

wa_texttable TYPE t_texttable.

* Used for the sytem event

call method cl_gui_cfw=>set_new_ok_code

exporting new_code = 'SHOW'.

* Read the position of the double click

CALL METHOD sender->get_selection_pos

IMPORTING

from_line = from_line

from_pos = from_pos

to_line = to_line

to_pos = to_pos.

* Texts in the TextEdit control can have been changed, so

* first reload text from the control into the internal

* table that contains text

IF NOT g_loaded IS INITIAL.

CALL METHOD sender->get_text_as_r3table

IMPORTING table = i_texttable.

* Read the line of the internal table that was clicked

READ TABLE i_texttable INDEX from_line INTO wa_texttable.

IF sy-subrc <> 0.

EXIT.

ENDIF.

IF wa_texttable+0(1) CS '*'.

SHIFT wa_texttable.

ELSEIF wa_texttable+0(1) NS '*'.

SHIFT wa_texttable RIGHT.

wa_texttable+0(1) = '*'.

ENDIF.

modify i_texttable from wa_texttable index from_line.

* Reload texts from h einternal table

perform load_texts.

ENDIF.

ENDMETHOD.

ENDCLASS.




START-OF-SELECTION.

CLEAR wa_events.

REFRESH: i_events.

SET SCREEN '100'.

*---------------------------------------------------------------------*

* MODULE USER_COMMAND_0100 INPUT *

*---------------------------------------------------------------------*

MODULE user_command_0100 INPUT.

CASE ok_code.

WHEN 'EXIT'.

LEAVE TO SCREEN 0.

WHEN 'SHOW'.

event_type = 'System dblclick'.

WHEN 'IMP'.

PERFORM Load_texts.

WHEN OTHERS.

* CALL METHOD cl_gui_cfw=>dispatch. "Not used for system events

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

*&---------------------------------------------------------------------*

*& Module STATUS_0100 OUTPUT

*&---------------------------------------------------------------------*

MODULE status_0100 OUTPUT.

* The TextEdit control shoul only be initialized the first time the

* PBO module executes

IF editor IS INITIAL.

repid = sy-repid.

* Create object for custom container

CREATE OBJECT custom_container

EXPORTING

container_name = 'MYCONTAINER1'

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

others = 6

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

* Create obejct for the TextEditor control

CREATE OBJECT editor

EXPORTING

wordwrap_mode =

cl_gui_textedit=>wordwrap_at_fixed_position

wordwrap_position = line_length

wordwrap_to_linebreak_mode = cl_gui_textedit=>true

parent = custom_container

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

gui_type_not_supported = 5

others = 6

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

* Link the event handler method to the event and the

* TextEdit control

SET HANDLER lcl_event_handler=>catch_dblclick FOR editor.

* Register the event in the internal table i_events

wa_events-eventid = cl_gui_textedit=>event_double_click.

* wa_events-appl_event = 'X'. "This is an application event

wa_events-appl_event = space. "This is a system event

APPEND wa_events TO i_events.

* Pass the table to the TextEdit control uding method

* set_registred_events

CALL METHOD editor->set_registered_events

EXPORTING events = i_events.

* Create internal table with texts taht can be uploaded to

* the TextEdit control

APPEND 'This a method that fills the TextEdit control' TO i_texttable.

APPEND 'with a text.' TO i_texttable.

DO 10 TIMES.

APPEND 'hallo world !' TO i_texttable.

ENDDO.




ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

*&---------------------------------------------------------------------*

*& Form Load_texts

*&---------------------------------------------------------------------*

* This form loads the lines of the internal table i_texttable into

* the TextEdit control

*----------------------------------------------------------------------*

FORM Load_texts.

* Load TextEdit control with texts

CALL METHOD editor->set_text_as_r3table

EXPORTING table = i_texttable.

IF sy-subrc > 0.

* Display an error message

EXIT.

ENDIF.

* All methods that operates on controls are transferred to the frontend

* by a RFC calls. the method FLUSH is used to determine when this is

* done.

CALL METHOD cl_gui_cfw=>flush.

IF sy-subrc > 0.

* Display an error message

ENDIF.

g_loaded = 'X'.

ENDFORM. " create_texts

Example 6: Protect a line in the TextEdit control and the importance of FLUSH

All methods that operates on controls are transfered to the fronend by RFC calls. The FLUSH method is used to synchronize control execution and the frontend. This is very important when working e.g. with export parameters from a method, as the parmeters will not be correct before the FLUSH method has been called.

The example below portects selected lines in the TextEdit and uses FLUSH to ensure that the correct parameters are returned from method GET_SELECTION_POS.

Note: Instead of using method PROTECT_LINES, the method PROTECT_SELECTION could be used. This method does not need line numbers or a FLUSH statement

Steps

* Add a new pushbutton to the screen with the function code PROTECT.

Code

Add the following code to the example:

* Global variables

DATA:

from_idx TYPE i,

to_idx TYPE i,

index TYPE i.

MODULE user_command_0100 INPUT.

CASE ok_code.

code.......................

WHEN 'PROTECT'.

PERFORM protect.




. .......................

ENDCASE.

*&amp;amp;amp;---------------------------------------------------------------------*

*& Form protect

*&---------------------------------------------------------------------*

* Protects marked lines in a TextEdit control

*----------------------------------------------------------------------*

FORM protect.

* Determine the area selected by the user

CALL METHOD editor->get_selection_pos

IMPORTING

from_line = from_idx

to_line = to_idx

EXCEPTIONS

error_cntl_call_method = 1.

* Synchronize execution in the control with the ABAP program.

* Without this synchronization the variables from_idx and

* to_idx will have obsolutete values (The initial value for

* both, are 0)

CALL METHOD cl_gui_cfw=>flush.

IF sy-subrc > 0.

* Errormessage: Error in flush

ENDIF.

* Protect the selected lines

IF to_idx > from_idx.

to_idx = to_idx - 1.

ENDIF.

CALL METHOD editor->protect_lines

EXPORTING

from_line = from_idx

to_line = to_idx.

* The PROTECT_SELECTION method could be used instead, eliminating the

* need of line numbers and the last FLUSH




* call method editor->protect_selection.

* Flush again to protect immidiately

CALL METHOD cl_gui_cfw=>flush.

IF sy-subrc > 0.

* Errormessage: Error in flush

ENDIF.




ENDFORM. " protect


Example 7: Using multiple controls

In this example a second TextEdit control will be added to the screen. The new TextEdit control will be designed to act as a clipboard for short texts.

Steps:

* Add a new container to the screen and name it MYCONTAINER2.



Code:

Insert global datadeclaration:

**********************************************************************

* Implementing a second Scratch TextEdit control

**********************************************************************

DATA:

scratch TYPE REF TO cl_gui_textedit,

custom_container2 TYPE REF TO cl_gui_custom_container.

Insert the following code in the PBO module:

*------------------------------------------------------

* The SCRATCH TextEdit control

*------------------------------------------------------

IF scratch IS INITIAL.

* Create obejct for custom container2

CREATE OBJECT custom_container2

EXPORTING

container_name = 'MYCONTAINER2'

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

others = 6

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

* Create obejct for the SCRATCH TextEditor control

CREATE OBJECT scratch

EXPORTING

parent = custom_container2

wordwrap_mode =

cl_gui_textedit=>wordwrap_at_windowborder

wordwrap_to_linebreak_mode = cl_gui_textedit=>true.

* Remove the staus bar

CALL METHOD scratch->set_statusbar_mode

EXPORTING statusbar_mode = cl_gui_textedit=>false.

ENDIF.

Result:

Archives

1990年1月15日   2007年1月14日   2007年1月15日   2007年1月16日   2007年1月17日   2007年1月18日   2007年1月19日   2007年1月20日   2007年1月22日   2007年1月23日   2007年1月24日   2007年1月25日   2007年1月26日   2007年1月27日   2007年1月29日   2007年1月30日   2007年1月31日   2007年2月1日   2007年2月2日   2007年2月3日   2007年3月13日   2007年5月15日   2007年5月16日   2007年6月2日  

This page is powered by Blogger. Isn't yours?