Skip to Content
author's profile photo Former Member
Former Member

OLE Excel - changing colum width

Hello hi,

I recently started trying out OLE for transfering of data. I am not too familiar with OLE but I am liking it and would like to learn more about this when I have the time.

My question right now, though is how to manipulate the colum width of a cell. So far the cell in my program seems to run like this ...

<b>FORM fill_cell USING i j bold val.

CALL METHOD OF h_excel 'Cells' = h_zl EXPORTING #1 = i #2 = j.

SET PROPERTY OF h_zl 'Value' = val .

GET PROPERTY OF h_zl 'Font' = h_f.

SET PROPERTY OF h_f 'Bold' = bold .

ENDFORM.</b>

I know it has something to do with this and declaring 'Column Width', I could be wrong. Though

Hope to hear from all of you soon. Take Care and Good Day.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 25, 2006 at 05:41 AM

    Hai Chad Cheng

    go through the following Links

    OLE

    http://www.sapgenie.com/abap/ole.htm

    http://help.sap.com/saphelp_46c/helpdata/en/59/ae3f2e488f11d189490000e829fbbd/frameset.htm

    Thanks & regards

    Sreenivasulu P

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 26, 2006 at 08:27 AM

    Hi,

    To set the column width for a cell try this statement:

    SET PROPERTY OF h_zl 'ColumnWidth' = '1'.

    where 1 represents the width in characters.

    Hope the answer is useful to u.

    Regards,

    Rahul.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 26, 2006 at 08:42 AM

    hi

    U can refer the example.This might help u

    &----


    *& Form DOWNLOAD_EXCEL

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM DOWNLOAD_EXCEL.

    DATA: L_PAGE_BRK TYPE C.

    TYPES:L_XLCONSTANT TYPE I.

    CONSTANTS: L_XLPAGEBREAKMANUAL TYPE L_XLCONSTANT VALUE -4135.

    DATA: L_X(5) TYPE C,

    L_Y(5) TYPE C,

    L_Z(3) TYPE N,

    L_R1(10) TYPE C,

    L_DATE(10) TYPE C,

    L_FILE LIKE RLGRAP-FILENAME,

    L_ROW TYPE I,

    L_STRING(100).

    DATA : L_MONTH1(3) TYPE C,

    L_MONTH2(3) TYPE C,

    L_MONTH3(3) TYPE C,

    L_AMOUNT LIKE IT_AMT-AMOUNT,

    L_QRTR TYPE I,

    L_LS_AMT LIKE IT_AMT-AMOUNT,

    L_ES_AMT LIKE IT_AMT-AMOUNT,

    L_CS_AMT LIKE IT_AMT-AMOUNT,

    L_PE_AMT LIKE IT_AMT-AMOUNT,

    L_TOTAL LIKE IT_AMT-AMOUNT,

    LV_AMOUNT(18) TYPE C,

    LV_AMOUNT_C(20) TYPE C.

    IF P_QRTR = 1.

    L_MONTH1 = 'JAN'.

    L_MONTH2 = 'FEB'.

    L_MONTH3 = 'MAR'.

    ELSEIF P_QRTR = 2.

    L_MONTH1 = 'APR'.

    L_MONTH2 = 'MAY'.

    L_MONTH3 = 'JUN'.

    ELSEIF P_QRTR = 3.

    L_MONTH1 = 'JUL'.

    L_MONTH2 = 'AUG'.

    L_MONTH3 = 'SEP'.

    ELSEIF P_QRTR = 4.

    L_MONTH1 = 'OCT'.

    L_MONTH2 = 'NOV'.

    L_MONTH3 = 'DEC'.

    ENDIF.

    SELECT T005~CURHA INTO GV_CURR

    FROM T005 INNER JOIN T001

    ON T005LAND1 = T001LAND1

    WHERE T001~BUKRS = P_BUKRS.

    ENDSELECT.

    • CONCATENATE P_FILE 'VAT.xls' INTO P_FILE SEPARATED BY '\'.

    • To Delete the redundant Data File

    • PERFORM SUB_FILE_DELETE USING P_FILE.

    1. Start Excel

    CLEAR G_ERROR_CODE.

    CREATE OBJECT G_EXCEL 'EXCEL.APPLICATION' NO FLUSH.

    PERFORM ERR_HDL.

    SET PROPERTY OF G_EXCEL 'Visible' = 1.

    PERFORM ERR_HDL.

    1. get list of workbooks, initially empty

    CALL METHOD OF G_EXCEL 'Workbooks' = G_MAPL.

    PERFORM ERR_HDL.

    CALL METHOD OF G_MAPL 'Add' = G_MAPL.

    PERFORM ERR_HDL.

    PERFORM FILL_CELL USING 2 1 1 TEXT-004.

    WRITE : /20 TEXT-004 CENTERED.

    CALL METHOD OF G_EXCEL 'Range' = G_OBJXLRANGE

    EXPORTING #1 = 'A2:B2'.

    SET PROPERTY OF G_OBJXLRANGE 'MERGECELLS' = 1.

    SET PROPERTY OF G_F 'Underline' = 2.

    PERFORM ERR_HDL.

    PERFORM FILL_CELL USING 4 2 1 TEXT-005.

    WRITE: 60 TEXT-005 CENTERED.

    CALL METHOD OF G_EXCEL 'Range' = G_OBJXLRANGE

    EXPORTING #1 = 'B4:D4'.

    SET PROPERTY OF G_OBJXLRANGE 'MERGECELLS' = 1.

    SET PROPERTY OF G_OBJXLRANGE 'HorizontalAlignment' = 3.

    PERFORM ERR_HDL.

    PERFORM FILL_CELL USING 5 2 0 L_MONTH1.

    WRITE: /20 L_MONTH1.

    PERFORM FILL_CELL USING 5 3 0 L_MONTH2.

    WRITE: 30 L_MONTH2.

    PERFORM FILL_CELL USING 5 4 0 L_MONTH3.

    WRITE: 40 L_MONTH3.

    PERFORM FILL_CELL USING 7 1 0 TEXT-006. "Purchase(AP)

    WRITE: TEXT-006.

    PERFORM FILL_CELL USING 8 1 0 TEXT-007. "Prepaid(VAT)

    WRITE: TEXT-007.

    PERFORM FILL_CELL USING 11 1 0 TEXT-008. "Local sales(AR)

    WRITE: TEXT-008.

    PERFORM FILL_CELL USING 12 1 0 TEXT-009. "Export Sales

    WRITE: TEXT-009.

    PERFORM FILL_CELL USING 13 1 0 TEXT-010. "Commission

    WRITE: TEXT-010.

    PERFORM FILL_CELL USING 14 1 0 TEXT-011. "Sale on PPE

    WRITE: TEXT-011.

    PERFORM FILL_CELL USING 15 1 0 TEXT-012. "W/H VAT

    WRITE: TEXT-012.

    PERFORM FILL_CELL USING 17 1 1 TEXT-013. "Net off

    WRITE: TEXT-013.

    DATA : L_COL TYPE I VALUE 2.

    SORT IT_AMT.

    LOOP AT IT_AMT.

    PERFORM CONVERT_AMOUNT USING GV_CURR IT_AMT-AMOUNT

    CHANGING IT_AMT-C_AMOUNT.

    MODIFY IT_AMT TRANSPORTING C_AMOUNT.

    ENDLOOP.

    LOOP AT IT_AMT WHERE TYP = 'IT'.

    CLEAR LV_AMOUNT_C.

    PERFORM FILL_CELL USING 8 L_COL 0 IT_AMT-C_AMOUNT.

    WRITE: IT_AMT-C_AMOUNT.

    L_AMOUNT = L_AMOUNT + IT_AMT-AMOUNT.

    PERFORM FILL_CELL USING 9 L_COL 1 IT_AMT-C_AMOUNT.

    WRITE:IT_AMT-C_AMOUNT.

    L_COL = L_COL + 1.

    ENDLOOP.

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_AMOUNT CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 8 6 0 LV_AMOUNT_C.

    WRITE: LV_AMOUNT_C.

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_AMOUNT CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 9 6 1 LV_AMOUNT_C.

    WRITE: LV_AMOUNT_C.

    CLEAR L_AMOUNT.

    CLEAR L_COL.

    L_COL = 2.

    LOOP AT IT_AMT WHERE TYP = 'LS'.

    PERFORM FILL_CELL USING 11 L_COL 0 IT_AMT-C_AMOUNT.

    WRITE: IT_AMT-C_AMOUNT.

    L_AMOUNT = L_AMOUNT + IT_AMT-AMOUNT.

    L_COL = L_COL + 1.

    ENDLOOP.

    • WRITE L_AMOUNT TO LV_AMOUNT CURRENCY GV_CURR.

    • CONDENSE LV_AMOUNT.

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_AMOUNT CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 11 6 0 LV_AMOUNT_C.

    WRITE:LV_AMOUNT_C.

    CLEAR L_AMOUNT.

    CLEAR L_COL.

    L_COL = 2.

    LOOP AT IT_AMT WHERE TYP = 'ES'.

    • CLEAR LV_AMOUNT_C.

    • PERFORM CONVERT_AMOUNT USING GV_CURR L_AMOUNT CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 12 L_COL 0 IT_AMT-C_AMOUNT.

    WRITE: IT_AMT-AMOUNT.

    L_AMOUNT = L_AMOUNT + IT_AMT-AMOUNT.

    L_COL = L_COL + 1.

    ENDLOOP.

    • CLEAR LV_AMOUNT.

    • WRITE L_AMOUNT TO LV_AMOUNT CURRENCY GV_CURR.

    • CONDENSE LV_AMOUNT.

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_AMOUNT CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 12 6 0 LV_AMOUNT_C.

    WRITE:LV_AMOUNT_C.

    CLEAR L_AMOUNT.

    CLEAR L_COL.

    L_COL = 2.

    LOOP AT IT_AMT WHERE TYP = 'CS'.

    PERFORM FILL_CELL USING 13 L_COL 0 IT_AMT-C_AMOUNT.

    WRITE: IT_AMT-C_AMOUNT.

    L_AMOUNT = L_AMOUNT + IT_AMT-AMOUNT.

    L_COL = L_COL + 1.

    ENDLOOP.

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_AMOUNT CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 13 6 0 LV_AMOUNT_C.

    WRITE:LV_AMOUNT_C.

    CLEAR L_AMOUNT.

    CLEAR L_COL.

    L_COL = 2.

    LOOP AT IT_AMT WHERE TYP = 'PE'.

    PERFORM FILL_CELL USING 14 L_COL 0 IT_AMT-C_AMOUNT.

    WRITE: IT_AMT-C_AMOUNT.

    L_AMOUNT = L_AMOUNT + IT_AMT-AMOUNT.

    L_COL = L_COL + 1.

    ENDLOOP.

    • CLEAR LV_AMOUNT.

    • WRITE L_AMOUNT TO LV_AMOUNT CURRENCY GV_CURR.

    • CONDENSE LV_AMOUNT.

    *

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_AMOUNT CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 14 6 0 LV_AMOUNT_C.

    WRITE:LV_AMOUNT_C.

    CLEAR L_AMOUNT.

    CLEAR L_COL.

    L_COL = 2.

    LOOP AT IT_AMT WHERE TYP = 'OT'.

    PERFORM FILL_CELL USING 15 L_COL 0 IT_AMT-C_AMOUNT.

    WRITE: IT_AMT-C_AMOUNT.

    L_AMOUNT = L_AMOUNT + IT_AMT-AMOUNT.

    PERFORM FILL_CELL USING 16 L_COL 1 IT_AMT-C_AMOUNT.

    WRITE: IT_AMT-C_AMOUNT.

    L_COL = L_COL + 1.

    ENDLOOP.

    • CLEAR LV_AMOUNT.

    • WRITE L_AMOUNT TO LV_AMOUNT CURRENCY GV_CURR.

    • CONDENSE LV_AMOUNT.

    *

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_AMOUNT CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 15 6 0 LV_AMOUNT_C.

    WRITE:LV_AMOUNT_C.

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_AMOUNT CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 16 6 1 LV_AMOUNT_C.

    WRITE:LV_AMOUNT_C.

    PERFORM FILL_CELL USING 4 6 1 TEXT-014. "Total

    WRITE: TEXT-014.

    CALL METHOD OF G_EXCEL 'Range' = G_OBJXLRANGE

    EXPORTING #1 = 'F4:F5'.

    SET PROPERTY OF G_OBJXLRANGE 'MERGECELLS' = 1.

    SET PROPERTY OF G_OBJXLRANGE 'HorizontalAlignment' = 3.

    PERFORM ERR_HDL.

    PERFORM FILL_CELL USING 4 7 1 TEXT-015. "Actual

    WRITE: TEXT-015.

    CALL METHOD OF G_EXCEL 'Range' = G_OBJXLRANGE

    EXPORTING #1 = 'G4:I4'.

    SET PROPERTY OF G_OBJXLRANGE 'MERGECELLS' = 1.

    SET PROPERTY OF G_OBJXLRANGE 'HorizontalAlignment' = 3.

    PERFORM ERR_HDL.

    PERFORM FILL_CELL USING 5 7 0 L_MONTH1.

    WRITE: L_MONTH1.

    PERFORM FILL_CELL USING 5 8 0 L_MONTH2.

    WRITE: L_MONTH2.

    PERFORM FILL_CELL USING 5 9 0 L_MONTH3.

    WRITE: L_MONTH3.

    PERFORM FILL_CELL USING 4 10 1 TEXT-014. "Total

    WRITE: TEXT-014.

    CALL METHOD OF G_EXCEL 'Range' = G_OBJXLRANGE

    EXPORTING #1 = 'J4:J5'.

    SET PROPERTY OF G_OBJXLRANGE 'MERGECELLS' = 1.

    SET PROPERTY OF G_OBJXLRANGE 'HorizontalAlignment' = 3.

    PERFORM ERR_HDL.

    PERFORM FILL_CELL USING 4 11 1 TEXT-016. "Difference

    WRITE: TEXT-016.

    PERFORM FILL_CELL USING 4 12 1 TEXT-017. "Adjustment

    WRITE: TEXT-017.

    PERFORM FILL_CELL USING 24 1 0 TEXT-018. "Reconcile.

    WRITE: TEXT-018.

    PERFORM FILL_CELL USING 25 1 0 TEXT-008. "Local sales

    WRITE: TEXT-008.

    PERFORM FILL_CELL USING 26 1 0 TEXT-009. "Export sales

    WRITE: TEXT-009.

    PERFORM FILL_CELL USING 27 1 0 TEXT-010. "Commission

    WRITE: TEXT-010.

    PERFORM FILL_CELL USING 28 1 0 TEXT-011. "Sale on PPE

    WRITE: TEXT-011.

    CALL METHOD OF G_EXCEL 'Range' = G_OBJXLRANGE

    EXPORTING #1 = 'K13:M13'.

    SET PROPERTY OF G_OBJXLRANGE 'MERGECELLS' = 1.

    SET PROPERTY OF G_OBJXLRANGE 'HorizontalAlignment' = 3.

    CLEAR : L_COL, L_LS_AMT, L_ES_AMT, L_CS_AMT, L_PE_AMT.

    L_QRTR = 1.

    L_COL = 2.

    DO.

    IF SY-INDEX = 1.

    PERFORM FILL_CELL USING 24 L_COL 0 TEXT-019. "1Q

    WRITE: TEXT-019.

    ELSEIF SY-INDEX = 2.

    PERFORM FILL_CELL USING 24 L_COL 0 TEXT-020. "2Q

    WRITE: TEXT-020.

    ELSEIF SY-INDEX = 3.

    PERFORM FILL_CELL USING 24 L_COL 0 TEXT-021. "3Q

    WRITE: TEXT-021.

    ELSEIF SY-INDEX = 4.

    PERFORM FILL_CELL USING 24 L_COL 0 TEXT-022. "4Q

    WRITE: TEXT-022.

    ENDIF.

    IF L_QRTR = P_QRTR .

    CLEAR L_TOTAL.

    • CLEAR LV_AMOUNT_C.

    • PERFORM CONVERT_AMOUNT USING GV_CURR L_AMOUNT

    • CHANGING LV_AMOUNT_C.

    PERFORM GET_AMOUNT USING 'LS' CHANGING L_AMOUNT.

    L_LS_AMT = L_LS_AMT + L_AMOUNT.

    L_TOTAL = L_TOTAL + L_AMOUNT.

    • CLEAR LV_AMOUNT.

    • WRITE L_AMOUNT TO LV_AMOUNT CURRENCY GV_CURR.

    • CONDENSE LV_AMOUNT.

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_AMOUNT

    CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 25 L_COL 0 LV_AMOUNT_C.

    WRITE: LV_AMOUNT_C.

    PERFORM GET_AMOUNT USING 'ES' CHANGING L_AMOUNT.

    L_ES_AMT = L_ES_AMT + L_AMOUNT.

    L_TOTAL = L_TOTAL + L_AMOUNT.

    • CLEAR LV_AMOUNT.

    • WRITE L_AMOUNT TO LV_AMOUNT CURRENCY GV_CURR.

    • CONDENSE LV_AMOUNT.

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_AMOUNT

    CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 26 L_COL 0 LV_AMOUNT_C.

    WRITE: LV_AMOUNT_C.

    PERFORM GET_AMOUNT USING 'CS' CHANGING L_AMOUNT.

    L_CS_AMT = L_CS_AMT + L_AMOUNT.

    L_TOTAL = L_TOTAL + L_AMOUNT.

    • CLEAR LV_AMOUNT.

    • WRITE L_AMOUNT TO LV_AMOUNT CURRENCY GV_CURR.

    • CONDENSE LV_AMOUNT.

    *

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_AMOUNT

    CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 27 L_COL 0 LV_AMOUNT_C.

    WRITE: LV_AMOUNT_C.

    PERFORM GET_AMOUNT USING 'PE' CHANGING L_AMOUNT.

    L_PE_AMT = L_PE_AMT + L_AMOUNT.

    L_TOTAL = L_TOTAL + L_AMOUNT.

    • CLEAR LV_AMOUNT.

    • WRITE L_AMOUNT TO LV_AMOUNT CURRENCY GV_CURR.

    • CONDENSE LV_AMOUNT.

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_AMOUNT

    CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 28 L_COL 0 LV_AMOUNT_C.

    WRITE: LV_AMOUNT_C.

    • CLEAR LV_AMOUNT.

    • WRITE L_TOTAL TO LV_AMOUNT CURRENCY GV_CURR.

    • CONDENSE LV_AMOUNT.

    *

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_TOTAL

    CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 29 L_COL 0 LV_AMOUNT_C.

    WRITE: LV_AMOUNT_C.

    EXIT.

    ENDIF.

    CLEAR L_AMOUNT.

    SELECT SINGLE * FROM ZVAT WHERE CCODE = P_BUKRS

    AND FYEAR = P_GJAHR

    AND QRTR = L_QRTR

    AND ACCT = '0501010000'.

    IF SY-SUBRC = 0.

    • CLEAR LV_AMOUNT.

    • WRITE ZVAT-AMOUNT TO LV_AMOUNT CURRENCY GV_CURR.

    • CONDENSE LV_AMOUNT.

    *

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR ZVAT-AMOUNT

    CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 25 L_COL 0 LV_AMOUNT_C.

    WRITE: LV_AMOUNT_C.

    L_AMOUNT = L_AMOUNT + ZVAT-AMOUNT.

    L_LS_AMT = L_LS_AMT + ZVAT-AMOUNT.

    ELSE.

    PERFORM FILL_CELL USING 25 L_COL 0 0.

    ENDIF.

    SELECT SINGLE * FROM ZVAT WHERE CCODE = P_BUKRS

    AND FYEAR = P_GJAHR

    AND QRTR = L_QRTR

    AND ACCT = '0501010630'.

    IF SY-SUBRC = 0.

    • CLEAR LV_AMOUNT.

    • WRITE ZVAT-AMOUNT TO LV_AMOUNT CURRENCY GV_CURR.

    • CONDENSE LV_AMOUNT.

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR ZVAT-AMOUNT

    CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 26 L_COL 0 LV_AMOUNT_C .

    • CLEAR LV_AMOUNT.

    • WRITE L_AMOUNT TO LV_AMOUNT CURRENCY GV_CURR.

    • CONDENSE LV_AMOUNT.

    *

    L_AMOUNT = L_AMOUNT + ZVAT-AMOUNT.

    L_ES_AMT = L_ES_AMT + ZVAT-AMOUNT.

    ELSE.

    PERFORM FILL_CELL USING 26 L_COL 0 0.

    WRITE: 0.

    ENDIF.

    SELECT SINGLE * FROM ZVAT WHERE CCODE = P_BUKRS

    AND FYEAR = P_GJAHR

    AND QRTR = L_QRTR

    AND ACCT = '0901071000'.

    IF SY-SUBRC = 0.

    • CLEAR LV_AMOUNT.

    • WRITE ZVAT-AMOUNT TO LV_AMOUNT CURRENCY GV_CURR.

    • CONDENSE LV_AMOUNT.

    *

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR ZVAT-AMOUNT

    CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 27 L_COL 0 LV_AMOUNT_C.

    WRITE: LV_AMOUNT_C.

    L_AMOUNT = L_AMOUNT + ZVAT-AMOUNT.

    L_CS_AMT = L_CS_AMT + ZVAT-AMOUNT.

    ELSE.

    PERFORM FILL_CELL USING 27 L_COL 0 0.

    WRITE: 0.

    ENDIF.

    SELECT SINGLE * FROM ZVAT WHERE CCODE = P_BUKRS

    AND FYEAR = P_GJAHR

    AND QRTR = L_QRTR

    AND ACCT = '0610000000'.

    IF SY-SUBRC = 0.

    • CLEAR LV_AMOUNT.

    • WRITE ZVAT-AMOUNT TO LV_AMOUNT CURRENCY GV_CURR.

    • CONDENSE LV_AMOUNT.

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR ZVAT-AMOUNT

    CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 28 L_COL 0 LV_AMOUNT_C.

    WRITE: LV_AMOUNT_C.

    L_AMOUNT = L_AMOUNT + ZVAT-AMOUNT.

    L_PE_AMT = L_PE_AMT + ZVAT-AMOUNT.

    ELSE.

    PERFORM FILL_CELL USING 28 L_COL 0 0.

    WRITE: 0.

    ENDIF.

    • CLEAR LV_AMOUNT.

    • WRITE L_AMOUNT TO LV_AMOUNT CURRENCY GV_CURR.

    • CONDENSE LV_AMOUNT.

    *

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_AMOUNT

    CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 29 L_COL 0 LV_AMOUNT_C.

    WRITE: LV_AMOUNT_C.

    L_QRTR = L_QRTR + 1.

    L_COL = L_COL + 1.

    ENDDO.

    L_COL = L_COL + 1.

    PERFORM FILL_CELL USING 24 L_COL 0 TEXT-023. "Total

    WRITE: TEXT-023.

    • CLEAR LV_AMOUNT.

    • WRITE L_LS_AMT TO LV_AMOUNT CURRENCY GV_CURR.

    • CONDENSE LV_AMOUNT.

    *

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_LS_AMT

    CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 25 L_COL 0 LV_AMOUNT_C.

    WRITE: LV_AMOUNT_C.

    • CLEAR LV_AMOUNT.

    • WRITE L_ES_AMT TO LV_AMOUNT CURRENCY GV_CURR.

    • CONDENSE LV_AMOUNT.

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_ES_AMT

    CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 26 L_COL 0 LV_AMOUNT_C.

    WRITE: LV_AMOUNT_C.

    • CLEAR LV_AMOUNT.

    • WRITE L_CS_AMT TO LV_AMOUNT CURRENCY GV_CURR.

    • CONDENSE LV_AMOUNT.

    *

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_CS_AMT

    CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 27 L_COL 0 LV_AMOUNT_C.

    WRITE: LV_AMOUNT_C.

    • CLEAR LV_AMOUNT.

    • WRITE L_PE_AMT TO LV_AMOUNT CURRENCY GV_CURR.

    • CONDENSE LV_AMOUNT.

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_PE_AMT

    CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 28 L_COL 0 LV_AMOUNT_C.

    WRITE: LV_AMOUNT_C.

    L_TOTAL = L_LS_AMT + L_ES_AMT + L_CS_AMT + L_PE_AMT.

    • CLEAR LV_AMOUNT.

    • WRITE L_TOTAL TO LV_AMOUNT CURRENCY GV_CURR.

    • CONDENSE LV_AMOUNT.

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_TOTAL

    CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 29 L_COL 0 LV_AMOUNT_C.

    WRITE: LV_AMOUNT_C.

    L_COL = L_COL + 1.

    PERFORM FILL_CELL USING 24 L_COL 0 TEXT-024. "TB(DEC)

    WRITE: TEXT-024.

    • CLEAR LV_AMOUNT.

    • WRITE L_LS_AMT TO LV_AMOUNT CURRENCY GV_CURR.

    • CONDENSE LV_AMOUNT.

    *

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_LS_AMT

    CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 25 L_COL 0 LV_AMOUNT_C.

    WRITE: LV_AMOUNT_C.

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_ES_AMT

    CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 26 L_COL 0 LV_AMOUNT_C.

    WRITE: LV_AMOUNT_C.

    CLEAR LV_AMOUNT_C.

    PERFORM CONVERT_AMOUNT USING GV_CURR L_CS_AMT

    CHANGING LV_AMOUNT_C.

    PERFORM FILL_CELL USING 27 L_COL 0 LV_AMOUNT_C.

    WRITE: LV_AMOUNT_C.

    • PERFORM FILL_CELL USING 28 L_COL 0 L_PE_AMT.

    L_COL = L_COL + 1.

    PERFORM FILL_CELL USING 24 L_COL 0 TEXT-025. "Description(Acct code)

    WRITE: TEXT-025.

    PERFORM FILL_CELL USING 25 L_COL 0 '501010000'.

    WRITE: '501010000'.

    PERFORM FILL_CELL USING 26 L_COL 0 '501010630'.

    WRITE: '501010630'.

    PERFORM FILL_CELL USING 27 L_COL 0 '0901071000'.

    WRITE: '9999999999'.

    PERFORM FILL_CELL USING 28 L_COL 0 '0610000000'.

    WRITE: '9999999999'.

    PERFORM FILL_CELL USING 21 11 1 TEXT-026."Diff description

    WRITE: TEXT-026.

    CALL METHOD OF G_EXCEL 'Columns' = G_ZLC .

    PERFORM ERR_HDL.

    CALL METHOD OF G_ZLC 'Autofit'.

    PERFORM ERR_HDL.

    CALL METHOD OF G_EXCEL 'ACTIVEWORKBOOK' = G_MAP .

    • CALL METHOD OF G_MAP 'SAVEAS' EXPORTING #1 = P_FILE.

    • SET PROPERTY OF g_map 'SAVED' = 1.

    CALL METHOD OF G_EXCEL 'QUIT'.

    ENDFORM. " DOWNLOAD_EXCEL

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 12:21 PM

    can any one tell how to implement the same logic when we use SO_NEW_DOCUMENT_API1 function module(excel attach sending as email)

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.