Code: Alles auswählen.
REPORT zz_bestellung_word .
TABLES: ekpo, eket, ekko, ekan, lfa1.
INCLUDE ole2incl.
INCLUDE docsincl.
DATA:
itab LIKE ekpo OCCURS 0 WITH HEADER LINE,
itaba LIKE eket OCCURS 0 WITH HEADER LINE,
itabb LIKE ekko OCCURS 0 WITH HEADER LINE,
itabc LIKE lfa1 OCCURS 0 WITH HEADER LINE,
h_word TYPE ole2_object.
DATA:
value(20) TYPE c,
quantity(15) TYPE c,
netvalue(20) TYPE c,
sum(20) TYPE c,
temp(16) TYPE p DECIMALS 2, " like itab-netpr,
temp2(16) TYPE p DECIMALS 2. " like itab-netpr.
PARAMETERS:
getorder LIKE ekpo-ebeln DEFAULT '**********',
contpers(80) TYPE c DEFAULT 'First second name',
telnr(15) TYPE c DEFAULT 'Telephonenumber'.
IF getorder NE ''.
PERFORM write_order.
ENDIF.
*---------------------------------------------------------------------*
* FORM WRITE_ORDER
*---------------------------------------------------------------------*
FORM write_order.
IF h_word-header = space OR h_word-handle EQ -1.
CREATE OBJECT h_word 'Word.Basic'.
CALL METHOD OF h_word 'FileNew' EXPORTING #1 = 'normal.dot'.
CALL METHOD OF h_word 'AppShow'.
CALL METHOD OF h_word 'ViewHeader'.
CALL METHOD OF h_word 'TableGridLines'
EXPORTING #1 = '0'.
CALL METHOD OF h_word 'TableInsertTable'
EXPORTING #1 = ' '
#2 = '2'
#3 = '1'
#4 = 'Auto'.
* call method of h_word 'InsertPicture'
* exporting #1 = 'c:\data\logo.bmp'.
PERFORM write_text
USING 'ERICSSON L' "text
'Ericsson' "font
'24' "size
'Bold'. "look
CALL METHOD OF h_word 'TableColumnWidth'
EXPORTING #01 = '9,0 cm'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'CloseViewHeaderFooter'.
CALL METHOD OF h_word 'TableInsertTable'
EXPORTING #1 = ' '
#2 = '2'
#3 = '1'
#4 = 'Auto'.
CALL METHOD OF h_word 'TableColumnWidth'
EXPORTING #01 = '9,0 cm'.
PERFORM write_text
USING 'Ericsson Data AB'
'TimesNewRoman '
'12'
''.
CALL METHOD OF h_word 'NextCell'.
DATA: order(21) TYPE c.
DATA: contact(80) TYPE c.
DATA: tsize TYPE i VALUE 0.
order = getorder.
order+10(3) = ' / '.
order+13(8) = sy-datum.
contact = contpers.
tsize = strlen( contact ).
contact+tsize(3) = ' / '.
tsize = strlen( contact ).
contact+tsize(15) = telnr.
PERFORM write_text
USING 'Purchase order' 'TimesNewRoman' '10' 'Italic'.
CALL METHOD OF h_word 'NextCell'.
PERFORM write_text USING 'BigCity' 'TimesNewRoman ' '12' ''.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NormalStyle'.
PERFORM write_text
USING 'PO number/date' 'TimesNewRoman' '14' 'Bold'.
CALL METHOD OF h_word 'NextCell'.
PERFORM write_text
USING 'STOCKHOLM SWEDEN' 'TimesNewRoman ' '12' ''.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NormalStyle'.
PERFORM write_text USING order 'TimesNewRoman' '10' 'Italic'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NormalStyle'.
PERFORM write_text
USING 'Contact person/Telephone' 'TimesNewRoman' '14' 'Bold'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NormalStyle'.
PERFORM write_text USING contact 'TimesNewRoman' '10' 'Italic'.
CALL METHOD OF h_word 'EndOfDocument'.
CALL METHOD OF h_word 'EndOfLine'.
CALL METHOD OF h_word 'InsertPara'.
SELECT * FROM ekpo WHERE ebeln EQ getorder.
itab = ekpo.
APPEND itab.
ENDSELECT.
SELECT * FROM ekko WHERE ebeln = getorder.
itabb = ekko.
APPEND itabb.
ENDSELECT.
SELECT * FROM lfa1 WHERE lifnr = itabb-lifnr.
itabc = lfa1.
ENDSELECT.
DATA: ind TYPE i VALUE 0.
LOOP AT itab.
IF ind = 0.
CALL METHOD OF h_word 'TableInsertTable'
EXPORTING #1 = ' '
#2 = '2'
#3 = '8'
#4 = 'Auto'.
CALL METHOD OF h_word 'TableColumnWidth'
EXPORTING #01 = '9,0 cm'.
PERFORM write_text
USING 'Your vendor number with us:'
'TimesNewRoman' '14' 'Bold'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NextCell'.
PERFORM write_text USING itabb-lifnr 'TimesNewRoman' '10' ''.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NormalStyle'.
PERFORM write_text
USING 'Payt. terms:' 'TimesNewRoman' '10' ''.
CALL METHOD OF h_word 'NextCell'.
PERFORM write_text
USING itabc-name1 'TimesNewRoman' '10' 'Bold'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NormalStyle'.
PERFORM write_text
USING 'Within 14 days 3% cash discount'
'TimesNewRoman' '10' ''.
CALL METHOD OF h_word 'NextCell'.
PERFORM write_text
USING itabc-stras 'TimesNewRoman' '10' 'Bold'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NormalStyle'.
PERFORM write_text
USING 'Within 20 days 2% cash discount'
'TimesNewRoman' '10' ''.
CALL METHOD OF h_word 'NextCell'.
PERFORM write_text
USING itabc-ort01 'TimesNewRoman' '10' 'Bold'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NormalStyle'.
PERFORM write_text
USING 'Within 30 days Due net'
'TimesNewRoman' '10' ''.
CALL METHOD OF h_word 'EndOfDocument'.
CALL METHOD OF h_word 'EndOfLine'.
CALL METHOD OF h_word 'InsertPara'.
* call method of h_word 'InsertLine'.
**********************************************************************
* call method of h_word 'InsertPara'.
* call method of h_word 'InsertPara'.
CALL METHOD OF h_word 'TableInsertTable'
EXPORTING #1 = ' '
#2 = '6'
#3 = '1'
#4 = 'Auto'.
CALL METHOD OF h_word 'TableColumnWidth'
EXPORTING #01 = '2,0 cm'.
PERFORM write_text
USING 'Material number' 'TimesNewRoman' '12' 'Bold'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'TableColumnWidth'
EXPORTING #01 = '4,0 cm'.
PERFORM write_text
USING 'Material description'
'TimesNewRoman' '12' 'Bold'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'TableColumnWidth'
EXPORTING #01 = '2,1 cm'.
PERFORM write_text
USING 'Quantity' 'TimesNewRoman' '12' 'Bold'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'TableColumnWidth'
EXPORTING #01 = '1,6 cm'.
PERFORM write_text
USING ' Unit' 'TimesNewRoman' '12' 'Bold'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'TableColumnWidth'
EXPORTING #01 = '3,0 cm'.
CALL METHOD OF h_word 'RightPara' EXPORTING #01 = 'AlignRight'.
PERFORM write_text
USING 'Price / Unit' 'TimesNewRoman' '12' 'Bold'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'TableColumnWidth'
EXPORTING #01 = '3,2 cm'.
CALL METHOD OF h_word 'RightPara'
EXPORTING #01 = 'AlignRight'.
PERFORM write_text
USING 'Net value' 'TimesNewRoman' '12' 'Bold'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NormalStyle'.
ENDIF.
PERFORM write_text USING itab-matnr 'TimesNewRoman' '10' ''.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NormalStyle'.
PERFORM write_text USING itab-txz01 'TimesNewRoman' '10' ''.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NormalStyle'.
MOVE itab-menge TO quantity. " Change to character
quantity = quantity(10). " Take away the decimals
PERFORM write_text USING quantity 'TimesNewRoman' '10' ''.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NormalStyle'.
PERFORM write_text USING itab-meins 'TimesNewRoman' '10' ''.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NormalStyle'.
CALL METHOD OF h_word 'RightPara' EXPORTING #01 = 'AlignRight'.
MOVE itab-netpr TO value. " Change numeric to character
PERFORM write_text USING value 'TimesNewRoman' '10' ''.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NormalStyle'.
CALL METHOD OF h_word 'RightPara' EXPORTING #01 = 'AlignRight'.
temp = quantity * itab-netpr.
MOVE temp TO netvalue. " Change numeric to character
PERFORM write_text USING netvalue 'TimesNewRoman' '10' ''.
ind = ind + 1.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NormalStyle'.
temp = quantity * itab-netpr.
MOVE temp TO netvalue. " Change numeric to character
temp2 = netvalue + temp2.
ENDLOOP.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'EndOfDocument'.
CALL METHOD OF h_word 'EndOfLine'.
CALL METHOD OF h_word 'InsertPara'.
CALL METHOD OF h_word 'TableInsertTable'
EXPORTING #1 = ' '
#2 = '4'
#3 = '1'
#4 = 'Auto'.
CALL METHOD OF h_word 'TableColumnWidth'
EXPORTING #01 = '4,6 cm'.
PERFORM write_text
USING 'Delivery Date' 'TimesNewRoman' '14' 'Bold'.
CALL METHOD OF h_word 'NextCell'.
**************
SELECT * FROM eket WHERE ebeln EQ getorder.
itaba = eket.
APPEND itaba.
ENDSELECT.
PERFORM write_text USING itaba-slfdt 'TimesNewRoman' '10' ''.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'TableColumnWidth'
EXPORTING #01 = '4,5 cm'.
PERFORM write_text
USING 'Total Net Value' 'TimesNewRoman' '14' 'Bold'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'TableColumnWidth'
EXPORTING #01 = '2,9 cm'.
CALL METHOD OF h_word 'RightPara'
EXPORTING #01 = 'AlignRight'.
MOVE temp2 TO sum. " Change numeric to character
PERFORM write_text USING sum 'TimesNewRoman' '10' ''.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'EndOfDocument'.
CALL METHOD OF h_word 'EndOfLine'.
CALL METHOD OF h_word 'InsertPara'.
CALL METHOD OF h_word 'TableInsertTable'
EXPORTING #1 = ' '
#2 = '2'
#3 = '6'
#4 = 'Auto'.
CALL METHOD OF h_word 'TableColumnWidth'
EXPORTING #01 = '8,0 cm'.
PERFORM write_text
USING 'Please deliver to:' 'TimesNewRoman' '14' 'Bold'.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NextCell'.
PERFORM write_text
USING 'Company name' 'TimesNewRoman' '10' ''.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NextCell'.
PERFORM write_text
USING 'Longstreet 111' 'TimesNewRoman' '10' ''.
CALL METHOD OF h_word 'NextCell'.
CALL METHOD OF h_word 'NextCell'.
PERFORM write_text
USING '11111 Stockholm' 'TimesNewRoman' '10' ''.
ENDIF.
IF sy-subrc NE 0.
WRITE: / 'Error when opening word.application', sy-msgli.
ENDIF.
FREE OBJECT h_word.
h_word-handle = -1.
ENDFORM.
*---------------------------------------------------------------------*
* FORM WRITE_TEXT *
*---------------------------------------------------------------------*
* --> TEXT
* --> FONT
* --> SIZE
* --> LOOK
*---------------------------------------------------------------------*
FORM write_text USING text font size look.
CALL METHOD OF h_word 'Font' EXPORTING #01 = font.
CALL METHOD OF h_word 'FontSize' EXPORTING #1 = size.
IF look NE ''.
CALL METHOD OF h_word look.
ENDIF.
CALL METHOD OF h_word 'Insert' EXPORTING #1 = text.
ENDFORM.Code: Alles auswählen.
FormFieldOptions Entry, Exit, Name, Enable, TextType, TextWidth, TextDefault, TextFormat, CheckSize, CheckWidth, CheckDefault, Type, OwnHelp, HelpText, OwnStat, StatTextBei Abtrennen von einen Spam-Eintrag ist leider der nachfolgende Post mit abgetrennt worde.xy hat geschrieben:Hallo!
Ich kann mit der Methode 'TableInsertTable' eine Tabelle in mein Worddokument einfügen. Aber kann mir jemand sagen wie ich um diese Tabelle einen Rahmen ziehen kann?
Danke im Voraus!