Skip to Content
0
Sep 19, 2007 at 10:01 AM

Open dataset......

172 Views

Hi Folks,

I am trying to get some data using Open dataset.The program is not showing any errors and executing fine,but I was not able to find the data that I am going to get using OPEN DATASET.Where will I be able to see the data.In the given path there is no file downloaded.Kindly let me know.

run the program

enter some data in the blank fields of the alv

save it

now double click on the qty1 field in the alv.

Thanks,

K.Kiran.

REPORT zlabel.

TYPE-POOLS:slis,icon.

TABLES:makt.

*Declarations for ALV

DATA:itfieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.

DATA:itfieldcat1 TYPE slis_t_fieldcat_alv WITH HEADER LINE.

DATA:itprintparams TYPE slis_print_alv.

DATA:itrepid TYPE sy-repid.

itrepid = sy-repid.

DATA:itevent TYPE slis_t_event.

DATA:itlistheader TYPE slis_t_listheader.

DATA:walistheader LIKE LINE OF itlistheader.

DATA:itlayout TYPE slis_layout_alv.

DATA:top TYPE slis_formname.

DATA:itsort TYPE slis_t_sortinfo_alv WITH HEADER LINE.

DATA : grid TYPE REF TO cl_gui_alv_grid.

*Declaration for DSN

<b>DATA : file(50) VALUE 'E:\userdata\labelfiles'.</b>

DATA : dsn(150).

DATA : dsn1(100).

DATA : n1(4) TYPE n.

*Declarations for Internal tables.

DATA:BEGIN OF imakt OCCURS 0,

matnr LIKE makt-matnr,

spras LIKE makt-spras,

maktx LIKE makt-maktx,

label1(03) TYPE c,

qty1(03) TYPE c,

label2(03) TYPE c,

qty2(03) TYPE c,

END OF imakt.

DATA:ITFINAL LIKE imakt OCCURS 0 WITH HEADER LINE.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS:matnr FOR makt-matnr OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.

PERFORM getdata.

IF sy-subrc = 0.

PERFORM alv.

ELSE.

STOP.

ENDIF.

&----


*& Form getdata

&----


  • text

----


FORM getdata.

SELECT matnr

spras

maktx

FROM makt

INTO CORRESPONDING FIELDS OF TABLE imakt

WHERE spras = sy-langu.

ENDFORM. "getdata

&----


*& Form ALV

&----


  • text

----


FORM alv.

DEFINE m_fieldcat.

itfieldcat-fieldname = &1.

itfieldcat-col_pos = &2.

itfieldcat-seltext_l = &3.

itfieldcat-do_sum = &4.

itfieldcat-outputlen = &5.

itfieldcat-edit = &6.

append itfieldcat to itfieldcat.

clear itfieldcat.

END-OF-DEFINITION.

m_fieldcat 'MATNR' '' 'MATERIAL No' '' 18 ''.

m_fieldcat 'SPRAS' '' 'Language' '' 02 ''.

m_fieldcat 'MAKTX' '' 'Description' '' 40 ''.

m_fieldcat 'LABEL1' '' 'LABEL1' '' 12 'X'.

m_fieldcat 'QTY1' '' 'QTY1' '' 12 'X'.

m_fieldcat 'LABEL2' '' 'LABEL2' '' 12 'X'.

m_fieldcat 'QTY2' '' 'QTY2' '' 12 'X'.

itlayout-zebra = 'X'.

itlayout-colwidth_optimize = 'X'.

itlayout-no_subtotals = ' '.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

is_layout = itlayout

  • i_callback_pf_status_set = 'PF_STATUS'

i_callback_user_command = 'LIST1'

i_callback_top_of_page = 'TOP'

it_fieldcat = itfieldcat[]

i_save = 'X'

  • is_variant = ITVARIANT

it_events = itevent[]

is_print = itprintparams

it_sort = itsort[]

TABLES

t_outtab = imakt

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

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

ENDIF.

CLEAR itfieldcat.

ENDFORM. "ALV

&----


*& Form list1

&----


  • text

----


  • -->R_UCOMM text

  • -->RS_SELFIELDtext

----


FORM list1 USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN 'EXIT'.

STOP.

ENDCASE.

CLEAR itfieldcat1.

REFRESH itfieldcat1.

DEFINE k_fieldcat.

itfieldcat1-fieldname = &1.

itfieldcat1-col_pos = &2.

itfieldcat1-seltext_l = &3.

itfieldcat1-outputlen = &4.

append itfieldcat1 to itfieldcat1.

clear itfieldcat1.

END-OF-DEFINITION.

k_fieldcat 'MATNR' '' 'MATERIAL No' 18 .

k_fieldcat 'SPRAS' '' 'Language' 02 .

k_fieldcat 'MAKTX' '' 'Description' 40 .

k_fieldcat 'LABEL1' '' 'LABEL1' 12 .

k_fieldcat 'QTY1' '' 'QTY1' 12 .

k_fieldcat 'LABEL2' '' 'LABEL2' 12 .

k_fieldcat 'QTY2' '' 'QTY2' 12 .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

is_layout = itlayout

  • i_callback_pf_status_set = 'PF_STATUS'

i_callback_user_command = 'LIST2'

i_callback_top_of_page = 'TOP'

it_fieldcat = itfieldcat1[]

i_save = 'X'

  • is_variant = ITVARIANT

it_events = itevent[]

is_print = itprintparams

it_sort = itsort[]

TABLES

t_outtab = imakt

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

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

ENDIF.

CLEAR:itfieldcat1,itfieldcat.

ENDFORM. "list1

&----


*& Form list2

&----


  • text

----


  • -->R_UCOMM text

  • -->RS_SELFIELDtext

----


FORM list2 USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN '&IC1'.

IF rs_selfield-fieldname = 'QTY1'.

LOOP AT IMAKT.

<b>CONCATENATE file n1 '.PJ' INTO dsn.</b>

<b> PERFORM DSN.</b>

CLEAR DSN.

N1 = N1 + 1.

ENDLOOP.

ENDIF.

ENDCASE.

ENDFORM. "list2

&----


*& Form top

&----


  • text

----


FORM top.

DATA:title(70) TYPE c.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = itevent

  • EXCEPTIONS

  • LIST_TYPE_WRONG = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

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

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

ENDIF.

title = 'LABEL'.

walistheader-typ = 'H'.

walistheader-info = title.

APPEND walistheader TO itlistheader.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = itlistheader

  • I_LOGO = ''.

  • I_END_OF_LIST_GRID =

.

CLEAR itlistheader.

ENDFORM. "TOP

&----


*& Form DSN

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


<b>form DSN .</b>

OPEN DATASET dsn FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc <> 0.

<b>LEAVE TO LIST-PROCESSING</b>

<b>WRITE:/ 'FILE COULD NOT BE OPENED'.</b>

EXIT.

ENDIF.

MOVE-CORRESPONDING IMAKT TO ITFINAL.

APPEND ITFINAL.

TRANSFER 'MDA.LBL' TO dsn.

TRANSFER '1' TO dsn.

TRANSFER: ITFINAL-MATNR TO DSN,

ITFINAL-SPRAS TO DSN,

ITFINAL-MAKTX TO DSN,

ITFINAL-LABEL1 TO DSN,

ITFINAL-QTY1 TO DSN,

ITFINAL-LABEL2 TO DSN,

ITFINAL-QTY2 TO DSN.

<b>if sy-subrc <> 0.</b>

write:/ 'Check your code'.

endif.

CLOSE DATASET DSN.

ENDFORM.