Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Export to Excel File

ratana_pouy
Participant
0 Likes
3,937

Dear All Expert,

I have created a new ABAP report, In ABAP report, i changed the BUM called KAR to CAR.

Everything is working well but after exported to excel file, it shows the star symbol in BUM column which has CAR.

This is the screenshot in ABAP report:

This the screenshot in Excel file:

How to resolve it?

Please help.....

With Warm Regards,

Ratana

1 ACCEPTED SOLUTION
Read only

former_member209120
Active Contributor
0 Likes
3,601

Hi Ratana Pouy.

Chang in your code like this


*    meins TYPE mseg-meins,  "Base Unit of Measure

meins TYPE char5,  "Base Unit of Measure


Dear All Expert,

I have created a new ABAP report, In ABAP report, i changed the BUM called KAR to CAR.

Everything is working well but after exported to excel file, it shows the star symbol in BUM column which has CAR.

This is the screenshot in ABAP report:

This the screenshot in Excel file:

How to resolve it?

Please help.....

With Warm Regards,

Ratana

15 REPLIES 15
Read only

paul_bakker2
Active Contributor
0 Likes
3,601

Hi,

You don't provide much detail. How are you exporting to Excel? Are you using an ALV table or something else? If it's ALV, are you using the standard 'Export to Excel' function?

cheers

Paul

Read only

ratana_pouy
Participant
0 Likes
3,601

Hi Paul,

I am using ALV table. At the top has one icon to export to excel file, but after exported i got the result as my posted above.

Any solution?

Cheers,

Ratana

Read only

Former Member
0 Likes
3,601

HI,

Make your BUM field of type 'C'  in your final table.

then it will export CV and CAR Value in BUM Field.

Regards,

Ravi Singh

Read only

0 Likes
3,601

Hi Ravi Singh,

Could you make me clear of your point?

Regards,

Ratana

Read only

0 Likes
3,601

HI,

Try This change and you will get the desired result..

TYPES: BEGIN OF ITEM_MATERIAL,

*       MENGE TYPE MSEG-MENGE,  "Quantity

        MEINS(5) TYPE C,  "Base Unit of Measure   "Add code by Ravi .

               END OF ITEM_MATERIAL.

Hope this will definately resolve your issue.

Regards,

Ravi Pratap Singh

Read only

bastinvinoth
Contributor
0 Likes
3,601

Hi Ratana Pouy

Can you check the excel column format, it could be solved by changing the formatting in excel

Regards,

Bastin.G

Read only

0 Likes
3,601

Dear Bastin.G,

Excel format column, you can check above screenshot.

Regards,

Ratana

Read only

0 Likes
3,601

Hi Ravi,

Did you check the date type in your program ?

also give details full whether you are downloading from Standard 'Export to Excel' function or Custom ?

if possible can you attach your code here, also check with other systems also if its easy

Regards,

Bastin.G

Read only

0 Likes
3,601

This is our source code:

REPORT  ZITEMSTOCK01.

TYPE-POOLS SLIS.

TABLES:MSEG, MKPF, MAKT,T006,LIKP,KNA1.

DATA : BEGIN OF I_VBPA OCCURS 0.

        INCLUDE STRUCTURE VBPA.

DATA : END OF I_VBPA.

DATA : BEGIN OF I_LFA1 OCCURS 0.

        INCLUDE STRUCTURE LFA1.

DATA : END OF I_LFA1.

DATA : BEGIN OF I_LIKP OCCURS 0.

        INCLUDE STRUCTURE LIKP.

DATA : END OF I_LIKP.

DATA : BEGIN OF I_KNA1 OCCURS 0.

        INCLUDE STRUCTURE KNA1.

DATA : END OF I_KNA1.

*perform eventtab_build using events[].

TYPES: BEGIN OF ITEM_MATERIAL,

    MATNR TYPE MSEG-MATNR,  "Material

    MAKTX TYPE MAKT-MAKTX,  "Material Description

    WERKS TYPE MSEG-WERKS,  "Plant

    LGORT TYPE MSEG-LGORT,  "Storage Location

    BWART TYPE MSEG-BWART,  "Movement Type

    MBLNR TYPE MSEG-MBLNR,  "Material Document

    BUDAT TYPE MKPF-BUDAT,  "Posting Date

    BLDAT TYPE MKPF-BLDAT,      "" Document date

    MENGE TYPE MSEG-MENGE,  "Quantity

    MEINS TYPE MSEG-MEINS,  "Base Unit of Measure

    XBLNR TYPE MKPF-XBLNR,  "Reference

    BKTXT TYPE MKPF-BKTXT,  "Document Header Text

    EBELN TYPE MSEG-EBELN,  "Purchase Order

    LIFNR TYPE MSEG-LIFNR,  "Vendor

    UMWRK TYPE MSEG-UMWRK,  "Receiving Plant

    UMLGO TYPE MSEG-UMLGO,  "Receiving Stor. Loc.

    SHKZG TYPE MSEG-SHKZG,  "Debit/Credit

    SGTXT TYPE MSEG-SGTXT,  "Long text of each item

    WEMPF TYPE MSEG-WEMPF,  "Recipient

    DO TYPE VBPA-VBELN,     "Delivery Number

    FA TYPE VBPA-LIFNR,     "" Forwarding Agent

    FA_NAME TYPE LFA1-NAME1,"" Forwarding Agent Name

    SOP TYPE LIKP-KUNAG,    "" Sold to party

    SOP_NAME TYPE KNA1-NAME1, "" Sold to party Name

END OF ITEM_MATERIAL.

DATA : IT_VALUE TYPE TABLE OF ITEM_MATERIAL. "Declare the IT_Value from ITEM_Material

DATA : WA_VALUE TYPE ITEM_MATERIAL.

DATA : INPUT(10) TYPE C,

      LONG_TEXT(10) TYPE C,

      OUTPUT(10) TYPE C,

      SHORT_TEXT(10) TYPE C.

DATA : FCAT TYPE SLIS_T_FIELDCAT_ALV   WITH HEADER LINE .

DATA  :  FSORT  TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE.

DATA : GD_REPID LIKE  SY-REPID.

DATA: L_LAYOUT TYPE SLIS_LAYOUT_ALV.

DATA: VAR TYPE DISVARIANT.

DATA    G_STATUS TYPE SLIS_FORMNAME VALUE 'ZSTANDARD'.

DATA:   GT_OUTTAB LIKE SIMLISTRUC OCCURS 0 WITH HEADER LINE.

DATA    G_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.

*DATA: BEGIN OF IT_S032 OCCURS 0,

*

*      MEINS TYPE MSEG-MEINS,

*

*END OF IT_S032.

SELECTION-SCREEN: BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS : MATNR   FOR MSEG-MATNR. " Material

SELECT-OPTIONS : WERKS   FOR MSEG-WERKS. " Plant

SELECT-OPTIONS : LGORT   FOR MSEG-LGORT. " Storage Location

SELECT-OPTIONS : LIFNR   FOR MSEG-LIFNR. " Vendor

SELECT-OPTIONS : BWART   FOR MSEG-BWART. " Movement Type

SELECT-OPTIONS : BUDAT   FOR MKPF-BUDAT. " Posting Date

SELECT-OPTIONS : XBLNR   FOR MKPF-XBLNR. " Posting Date

SELECTION-SCREEN : END OF BLOCK A1.

INITIALIZATION.

  VAR-REPORT = SY-REPID.

START-OF-SELECTION.

START-OF-SELECTION.

  SELECT

      MSEG~MATNR  "Material

      MAKT~MAKTX  "Material Description

      MSEG~WERKS  "Plant

      MSEG~LGORT  "Storage Location

      MSEG~BWART  "Movement Type

      MSEG~MBLNR  "Material Document

      MKPF~BUDAT  "Posting Date

      MKPF~BLDAT    "Material Document Date

      MSEG~MENGE  "Quantity

      MSEG~MEINS  "Base Unit of Measure

      MKPF~XBLNR  "Reference

      MKPF~BKTXT  "Document Header Text

      MSEG~EBELN  "Purchase Order

      MSEG~LIFNR  "Vendor

      MSEG~UMWRK  "Receiving Plant

      MSEG~UMLGO  "Receiving Stor. Loc.

      MSEG~SHKZG  "Debit/Credit

      MSEG~SGTXT  "Long text of each item

      MSEG~WEMPF  "Recipient

  FROM MSEG INNER JOIN MAKT ON MSEG~MATNR EQ MAKT~MATNR

      INNER JOIN MKPF ON MKPF~MBLNR EQ MSEG~MBLNR

  INTO TABLE IT_VALUE

  WHERE

  MSEG~MATNR IN MATNR AND

  MSEG~WERKS IN WERKS AND

  MSEG~LGORT IN LGORT AND

  MSEG~LIFNR IN LIFNR AND

  MSEG~BWART IN BWART AND

  MKPF~BUDAT IN BUDAT AND

  MKPF~XBLNR IN XBLNR.

END-OF-SELECTION.

  PERFORM CHANGE_DATA.

  PERFORM CALL_ALV.

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

*&      Form  CHANGE_DATA

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

*       text

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

FORM CHANGE_DATA .

  LOOP AT IT_VALUE INTO WA_VALUE.

    CLEAR : INPUT,LONG_TEXT,OUTPUT,SHORT_TEXT.

    IF WA_VALUE-SHKZG EQ 'H' .

      WA_VALUE-MENGE =   WA_VALUE-MENGE * -1.

    ENDIF.

    WA_VALUE-DO = WA_VALUE-XBLNR.  "" data type same for delivery number

    INPUT = WA_VALUE-MEINS.

    CALL FUNCTION 'CONVERSION_EXIT_CUNIT_OUTPUT'

      EXPORTING

        INPUT               = INPUT

       LANGUAGE             = SY-LANGU

     IMPORTING

       LONG_TEXT            = LONG_TEXT

       OUTPUT               = OUTPUT

       SHORT_TEXT           = SHORT_TEXT

*     EXCEPTIONS

*       UNIT_NOT_FOUND       = 1

*       OTHERS               = 2

              .

    IF SY-SUBRC = 0.

      MOVE OUTPUT TO WA_VALUE-MEINS.

    ENDIF.

    MODIFY IT_VALUE FROM WA_VALUE TRANSPORTING MENGE DO MEINS.

  ENDLOOP.

  SELECT * FROM VBPA INTO TABLE I_VBPA FOR ALL ENTRIES IN IT_VALUE WHERE VBELN = IT_VALUE-DO

                                                                   AND   PARVW = 'SP'.

  IF NOT I_VBPA[] IS INITIAL.

    SELECT * FROM LFA1 INTO TABLE I_LFA1 FOR ALL ENTRIES IN I_VBPA WHERE LIFNR = I_VBPA-LIFNR.

    SELECT  * FROM LIKP INTO TABLE I_LIKP FOR ALL ENTRIES IN I_VBPA WHERE VBELN = I_VBPA-VBELN.

    IF NOT I_LIKP[] IS INITIAL.

      SELECT * FROM KNA1 INTO TABLE I_KNA1 FOR ALL ENTRIES IN I_LIKP WHERE KUNNR = I_LIKP-KUNAG.

    ENDIF.

  ENDIF.

  LOOP AT IT_VALUE INTO WA_VALUE.

    CLEAR : I_VBPA,I_LFA1,I_LIKP,I_KNA1.

    READ TABLE I_VBPA WITH KEY VBELN = WA_VALUE-DO.

    IF SY-SUBRC = 0.

      READ TABLE I_LFA1 WITH KEY LIFNR = I_VBPA-LIFNR.

      IF SY-SUBRC = 0.

        MOVE I_LFA1-LIFNR TO WA_VALUE-FA.

        MOVE I_LFA1-NAME1 TO WA_VALUE-FA_NAME.

      ENDIF.

    ENDIF.

    READ TABLE I_LIKP WITH KEY VBELN = WA_VALUE-DO.

    IF SY-SUBRC = 0.

      READ TABLE I_KNA1 WITH KEY KUNNR = I_LIKP-KUNAG.

      IF SY-SUBRC = 0.

        MOVE I_KNA1-KUNNR TO WA_VALUE-SOP.

        MOVE I_KNA1-NAME1 TO WA_VALUE-SOP_NAME.

      ENDIF.

    ENDIF.

    MODIFY IT_VALUE FROM WA_VALUE TRANSPORTING FA FA_NAME SOP SOP_NAME.

    CLEAR WA_VALUE.

  ENDLOOP.

*  BREAK RBARTHWAL.

************* end of Addition by Rakesh Barthwal ************************

ENDFORM.                    "CHANGE_DATA

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

*&      Form  call_alv

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

*       text

FORM CALL_ALV.

  CLEAR: FCAT.

  REFRESH: FCAT.

*  DATA: fcat TYPE SLIS_FCAT_ALV.

  FCAT-COL_POS = '1'.

  FCAT-FIELDNAME = 'MATNR' .

  FCAT-OUTPUTLEN = '18'.

  FCAT-SELTEXT_L = 'Material'.

  APPEND FCAT .

  CLEAR FCAT.

  FCAT-COL_POS = '2'.

  FCAT-FIELDNAME = 'MAKTX' .

  FCAT-OUTPUTLEN = '18'.

  FCAT-SELTEXT_L = 'Material Description'.

  APPEND FCAT .

  CLEAR FCAT.

  FCAT-COL_POS = '3'.

  FCAT-FIELDNAME = 'WERKS' .

  FCAT-OUTPUTLEN = '6'.

  FCAT-SELTEXT_L = 'Plant'.

  APPEND FCAT .

  CLEAR FCAT.

  FCAT-COL_POS = '4'.

  FCAT-FIELDNAME = 'LGORT' .

  FCAT-OUTPUTLEN = '4'.

  FCAT-SELTEXT_L = 'Str.Loc.'.

  APPEND FCAT .

  CLEAR FCAT.

  FCAT-COL_POS = '5'.

  FCAT-FIELDNAME = 'BWART' .

  FCAT-OUTPUTLEN = '4'.

  FCAT-SELTEXT_L = 'Mvm. Type.'.

  APPEND FCAT .

  CLEAR FCAT.

  FCAT-COL_POS = '6'.

  FCAT-FIELDNAME = 'MBLNR' .

  FCAT-OUTPUTLEN = '12'.

  FCAT-SELTEXT_L = 'Material Doc.'.

  APPEND FCAT .

  CLEAR FCAT.

  FCAT-COL_POS = '7'.

  FCAT-FIELDNAME = 'BUDAT' .

  FCAT-OUTPUTLEN = '10'.

  FCAT-SELTEXT_L = 'Posting Date'.

  APPEND FCAT .

  CLEAR FCAT.

  FCAT-COL_POS = '7'.

  FCAT-FIELDNAME = 'BLDAT' .

  FCAT-OUTPUTLEN = '10'.

  FCAT-SELTEXT_L = 'Document Date'.

  APPEND FCAT .

  CLEAR FCAT.

  FCAT-COL_POS = '8'.

  FCAT-FIELDNAME = 'MENGE' .

  FCAT-OUTPUTLEN = '13'.

  FCAT-SELTEXT_L = 'Quantity'.

  APPEND FCAT .

  CLEAR FCAT.

  FCAT-COL_POS = '9'.

  FCAT-FIELDNAME = 'MEINS' .

  FCAT-OUTPUTLEN = '5'.

  FCAT-SELTEXT_L = 'BUM'.

  APPEND FCAT .

  CLEAR FCAT.

  FCAT-COL_POS = '10'.

  FCAT-FIELDNAME = 'XBLNR' .

  FCAT-OUTPUTLEN = '16'.

  FCAT-SELTEXT_L = 'Reference'.

  APPEND FCAT .

  CLEAR FCAT.

  FCAT-COL_POS = '11'.

  FCAT-FIELDNAME = 'BKTXT' .

  FCAT-OUTPUTLEN = '25'.

  FCAT-SELTEXT_L = 'Doc.Header Text'.

  APPEND FCAT .

  CLEAR FCAT.

  FCAT-COL_POS = '12'.

  FCAT-FIELDNAME = 'EBELN' .

  FCAT-OUTPUTLEN = '10'.

  FCAT-SELTEXT_L = 'Purchase Order'.

  APPEND FCAT .

  CLEAR FCAT.

  FCAT-COL_POS = '13'.

  FCAT-FIELDNAME = 'LIFNR' .

  FCAT-OUTPUTLEN = '10'.

  FCAT-SELTEXT_L = 'Vendor'.

  APPEND FCAT .

  CLEAR FCAT.

  FCAT-COL_POS = '14'.

  FCAT-FIELDNAME = 'UMWRK' .

  FCAT-OUTPUTLEN = '6'.

  FCAT-SELTEXT_L = 'Rec. Plant'.

  APPEND FCAT .

  CLEAR FCAT.

  FCAT-COL_POS = '15'.

  FCAT-FIELDNAME = 'UMLGO' .

  FCAT-OUTPUTLEN = '6'.

  FCAT-SELTEXT_L = 'Rec. Stor. Loc.'.

  APPEND FCAT .

  CLEAR FCAT.

  FCAT-COL_POS = '16'.

  FCAT-FIELDNAME = 'SGTXT' .

  FCAT-OUTPUTLEN = '25'.

  FCAT-SELTEXT_L = 'Text'.

  APPEND FCAT .

  CLEAR FCAT.

  FCAT-COL_POS = '17'.

  FCAT-FIELDNAME = 'WEMPF' .

  FCAT-OUTPUTLEN = '10'.

  FCAT-SELTEXT_L = 'Recipient'.

  APPEND FCAT .

  CLEAR FCAT.

  FCAT-COL_POS = '18'.

  FCAT-FIELDNAME = 'FA' .

  FCAT-OUTPUTLEN = '10'.

  FCAT-SELTEXT_L = 'Forwarding Agent No'.

  APPEND FCAT .

  CLEAR FCAT.

  FCAT-COL_POS = '19'.

  FCAT-FIELDNAME = 'FA_NAME' .

  FCAT-OUTPUTLEN = '25'.

  FCAT-SELTEXT_L = 'Forwarding Agent Name'.

  APPEND FCAT .

  CLEAR FCAT.

  FCAT-COL_POS = '20'.

  FCAT-FIELDNAME = 'SOP' .

  FCAT-OUTPUTLEN = '10'.

  FCAT-SELTEXT_L = 'Sold To Part'.

  APPEND FCAT .

  CLEAR FCAT.

  FCAT-COL_POS = '21'.

  FCAT-FIELDNAME = 'SOP_NAME' .

  FCAT-OUTPUTLEN = '25'.

  FCAT-SELTEXT_L = 'Sold To Party Name'.

  APPEND FCAT .

  CLEAR FCAT.

  GD_REPID = SY-REPID.

  PERFORM LAYOUT_INIT CHANGING L_LAYOUT.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

      EXPORTING

      I_CALLBACK_PROGRAM       = GD_REPID

*      I_CALLBACK_PF_STATUS_SET = G_STATUS

*      I_CALLBACK_USER_COMMAND  = G_USER_COMMAND

*      IS_LAYOUT                = L_LAYOUT

        IT_FIELDCAT              = FCAT[]

        IT_SORT                  = FSORT[]

        I_SAVE                   = 'A'

        IS_VARIANT               = VAR

      TABLES

        T_OUTTAB                 = IT_VALUE.

*  BREAK-POINT.

  IF SY-SUBRC <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.

ENDFORM.                    "call_alv

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

*&      Form  LAYOUT_INIT

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

*       text

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

*      <--P_L_LAYOUT  text

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

FORM LAYOUT_INIT   USING

I_LAYOUT TYPE SLIS_LAYOUT_ALV.

*  BREAK-POINT.

  CLEAR L_LAYOUT.

  I_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

ENDFORM.                    " LAYOUT_INIT

Read only

0 Likes
3,601

HI,

Try This change and you will get the desired result..

TYPES: BEGIN OF ITEM_MATERIAL,

*       MENGE TYPE MSEG-MENGE,  "Quantity

        MEINS(5) TYPE C,  "Base Unit of Measure   "Add code by Ravi .

               END OF ITEM_MATERIAL.

Hope this will definately resolve your issue.

Regards,

Ravi Pratap SinghSingh

Read only

0 Likes
3,601

Hi Ratan,

Problem with data type .

i have run the program and i got same like which you got **** in excel file

after that i have realized , there's a problem with data type

so can you make change there ? Change MEINS into CHAR type in your program

hope it helps

Regards,

Bastin.G

Read only

Former Member
0 Likes
3,601

Hi,

Try Download with unconverted format like .TXT....

if it work fine you can you the excel conversion function modules to convert your IT_DATA....

Read only

Former Member
0 Likes
3,601

Even check the data KAR to CAR saved in the data base.

Read only

former_member209120
Active Contributor
0 Likes
3,602

Hi Ratana Pouy.

Chang in your code like this


*    meins TYPE mseg-meins,  "Base Unit of Measure

meins TYPE char5,  "Base Unit of Measure


Read only

gurunathkumar_dadamu
Active Contributor
0 Likes
3,601

Hi Ratana,

Please trt to change the data type as Char type according to Bastin's reply.am sure that this is the data type problem only.

Let me know if any issues.

Regards,

Gurunath Kumar D