Application Development 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: 

excel file creation on application server

Former Member
0 Kudos

Gurus,

I have seen a lot of threads on excel file creation in application server, but failed to see if anyone had a solution.

Problem: In background execution I need to create an excel sheet on application server, the data would be contained in internal table, The FM like WS_DOWNLOAD etc..cannot support these as they have GUI component.

All the documentation that I have been through states to use dataset which saves the file in.csv or txt format seperated by delimiter, is it possible to save as a true excel file.

same as this thread:

let me know,

Thanks in advance .

1 ACCEPTED SOLUTION

former_member376453
Contributor
0 Kudos

I don't think in background you can save a file in excel format. In Application server , you can store a file with some delimiter. The extension you are using, behaving as a part of the name only.

Kuntal

8 REPLIES 8

Former Member
0 Kudos

hi Himanshu,

use the transaction CG3Z.

to create or move excel file from Presentation path to Application server.

regards,

Prabhudas

Former Member
0 Kudos

Prabhu,

Thanks, but I want to do it in background from my program.

0 Kudos

Edited by: Prabhu Das on Apr 29, 2009 12:54 AM

Edited by: Prabhu Das on Apr 29, 2009 1:01 AM

Edited by: Prabhu Das on Apr 29, 2009 1:05 AM

former_member376453
Contributor
0 Kudos

I don't think in background you can save a file in excel format. In Application server , you can store a file with some delimiter. The extension you are using, behaving as a part of the name only.

Kuntal

0 Kudos

* Write column headers, if required
  IF column_headers = 'X'.

*   ... override field names with LABELS_IN, if specified
    IF NOT labels_in[] IS INITIAL.
      DESCRIBE TABLE labels_in LINES num_lines.
      IF num_lines > num_fields.
        RAISE too_many_labels.
      ELSEIF num_lines < num_fields.
        RAISE too_few_labels.
      ENDIF.
      ASSIGN COMPONENT 1 OF STRUCTURE labels_in TO <f>.
      LOOP AT fields_in.
        READ TABLE labels_in INDEX sy-tabix.
        fields_in-name = labels_in-name.
        MODIFY fields_in.
      ENDLOOP.
    ENDIF.

*   ...write column headers to file...
    position = 0.
    LOOP AT fields_in.
      IF fixed_length NE space.

*** INSERT: DAR was here for Issue 17817 --------------- dar012009 ---v
        field_len = STRLEN( fields_in-name ).
*** INSERT: DAR was here for Issue 17817 --------------- dar012009 ---^

        DO fields_in-len TIMES.
          offset = sy-index - 1.
*          IF sy-index > 15.                                 dar012009
          IF sy-index > field_len.                          "dar012009
            line_out+position(1) = space.
          ELSEIF fields_in-name+offset(1) NE space.
            line_out+position(1) = fields_in-name+offset(1).
          ELSE.
            line_out+position(1) = space.
          ENDIF.
          position = position + 1.
        ENDDO.
      ELSE.
        CONCATENATE line_out fields_in-name INTO line_out
          SEPARATED BY delimiter.
      ENDIF.
    ENDLOOP.
    IF fixed_length EQ space.
      SHIFT line_out LEFT DELETING LEADING delimiter.
    ENDIF.
    IF no_write IS INITIAL.                                 "dar041505
      TRANSFER line_out TO file_out.
    ENDIF.                                                  "dar041505
    data_out = line_out.  APPEND data_out.                  "dar041505

  ENDIF.

* Write lines to file...
  LOOP AT data_in.
    CLEAR line_out.
    position = 0.
    DO num_fields TIMES.
      ASSIGN COMPONENT sy-index OF STRUCTURE data_in TO <f>.

0 Kudos

hi

Edited by: Prabhu Das on Apr 29, 2009 1:05 AM

0 Kudos

Prabhu,

Thx a lot for your mail!!! .

However, this puts the file in txt format and depends on excel to read it. its not a true excel file. Correct me if I am wrong,

Thanks,

Himanshu

0 Kudos

Hello,

I don't know how to save an excel file to a presentation server from a background job (SAP doesn't approve of that sort of thing) but I've been playing with report BCS_EXAMPLE_7 that allows you to send an email with a excel file as an attachment. You may find this an acceptable workaround. I'm still trying to find out how to do anything fancy with this approach (change fonts, cell formats, etc.) but for a straight up report it works very well.

Regards,

Michael