Object of class doesn't exist error after SELECT - abap

This is the Open Sales Order Report im working on.
im trying to read data from table VBUK and the VBELN field
im trying to get the data from table 'VAPMA' where the error occurred.
I get the following error after the second select statement.
object of class re and language en does not exist
Program:
*&---------------------------------------------------------------------*
*& Report ZRSD_DISPLAY_OPEN_SALESORDERS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZRSD_DISPLAY_OPEN_SALESORDERS.
TABLES: VAPMA,LIKP.
PARAMETERS: P_VKORG TYPE VAPMA-VKORG,
P_VTWEG TYPE VAPMA-VTWEG,
P_SPART TYPE VAPMA-SPART.
SELECT-OPTIONS:
S_KUNNR FOR VAPMA-KUNNR,
S_VBELN FOR VAPMA-VBELN,
S_MATNR FOR VAPMA-MATNR,
S_AUART FOR VAPMA-AUART,
S_AUDAT FOR VAPMA-AUDAT,
S_LFDAT FOR LIKP-LFDAT.
TYPES: BEGIN OF TY_VBELN,
VBELN TYPE VBUK-VBELN,
END OF TY_VBELN.
DATA : IT_VBELN TYPE STANDARD TABLE OF TY_VBELN,
IT1_VBELN TYPE STANDARD TABLE OF TY_VBELN,
IT2_VBELN TYPE STANDARD TABLE OF TY_VBELN,
WA_VBELN TYPE TY_VBELN.
SELECT VBELN INTO TABLE IT_VBELN FROM VBUK WHERE GBSTK NE 'C'.
IF SY-SUBRC NE 0.
message E000(ZMSG) WITH 'SEL1'.
ENDIF.
SELECT VBELN INTO TABLE IT1_VBELN FROM VAPMA
FOR ALL ENTRIES IN IT_VBELN
WHERE VBELN = IT_VBELN-VBELN AND
VKORG = P_VKORG AND
VTWEG = P_VTWEG AND
SPART = P_SPART AND
KUNNR IN S_KUNNR AND
VBELN IN S_VBELN AND
MATNR IN S_MATNR AND
AUART IN S_AUART AND
AUDAT IN S_AUDAT.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
SELECT VBELN INTO TABLE IT2_VBELN FROM LIKP
FOR ALL ENTRIES IN IT1_VBELN
WHERE VBELN = IT1_VBELN-VBELN AND
LFDAT IN S_LFDAT.
IF SY-SUBRC NE 0.
message E000(ZMSG) WITH 'SEL3'.
ENDIF.
LOOP AT IT2_VBELN INTO WA_VBELN.
WRITE:/1 WA_VBELN-VBELN.
ENDLOOP.

It is very likely that the error message that you are getting is not relevant to the problem:
If SY-SUBRC <> 0 after this select statement, it means that no data was found for the criteria that you have in your SELECT. However, SAP does not fill the SY-MSG* variables when a SELECT fails. As such whatever is still in memory from the last message that was displayed will be displayed.
SELECT VBELN INTO TABLE IT1_VBELN
FROM VAPMA
FOR ALL ENTRIES IN IT_VBELN
WHERE VBELN = IT_VBELN-VBELN AND
VKORG = P_VKORG AND
VTWEG = P_VTWEG AND
SPART = P_SPART AND
KUNNR IN S_KUNNR AND
VBELN IN S_VBELN AND
MATNR IN S_MATNR AND
AUART IN S_AUART AND
AUDAT IN AUDAT.
IF SY-SUBRC <> 0.
"From what you describing it sounds like you're triggering this error message
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Mirrorring what you have done on the other two selects I would think that you would want to use the following message in stead:
IF SY-SUBRC NE 0.
message E000(ZMSG) WITH 'SEL2'.
ENDIF.

Related

Want to show all lines items in result list instead of the last line item

I have a SELECT query with the aggregate function group by. But my program shows only the last line items. I want to show all the line items.
Example of expected result:
{"numOfRec":"50",
"shipmentsDetails":[
{"orderNum":"1000101730",
"deliveryOrderNum":"0085099852",
"prodCode":"OE8002L18",
"batchCode":"0000029927",
"qty":"108.000" } ,
{"orderNum":"1000101730",
"deliveryOrderNum":"0085099852",
"prodCode":"OE8407L18",
"batchCode":"0000029928",
"qty":"36.000" } ,
{"orderNum":"1000101730",
"deliveryOrderNum":"0085099852",
"prodCode":"SUE9433G1",
"batchCode":"0000029923",
"qty":"180.000" }]}
Example of actual result (in i_output):
{"numOfRec":"1",
"shipmentsDetails":[
{"orderNum":"1000101760",
"deliveryOrderNum":"0085099889",
"prodCode":"UE9101G5",
"batchCode":"20200101E",
"qty":"10.000" }]}
(although there are many line items, only the last line item is showing)
Here's my code:
IF NOT i_vttk IS INITIAL.
SELECT tknum
tpnum
vbeln
FROM vttp
INTO TABLE i_vttp
FOR ALL ENTRIES IN i_vttk
WHERE tknum = i_vttk-tknum.
IF sy-subrc EQ 0.
SORT i_vttp BY tknum tpnum.
ENDIF.
IF NOT i_vttp is INITIAL.
LOOP AT i_vttp INTO wa_vttp.
SELECT vbeln
matnr
charg
SUM( lgmng ) as lgmng
meins
FROM lips
INTO TABLE i_lips
WHERE vbeln = wa_vttp-vbeln
AND aedat LE sy-datum
AND lfimg <> 0
GROUP BY vbeln matnr charg meins.
IF sy-subrc EQ 0.
"APPEND i_lips.
"CLEAR i_lips.
SORT i_lips BY vbeln matnr.
ENDIF.
ENDLOOP.
ENDIF.
LOOP AT i_lips INTO wa_lips.
READ TABLE i_vttp
INTO wa_vttp
WITH KEY vbeln = wa_lips-vbeln.
IF sy-subrc = 0.
wa_output-tknum = wa_vttp-tknum.
wa_output-vbeln = wa_lips-vbeln. " Added Delivery
wa_output-matnr = wa_lips-matnr.
wa_output-charg = wa_lips-charg.
wa_output-lgmng = wa_lips-lgmng.
ENDIF.
APPEND wa_output TO i_output.
CLEAR: wa_vttp, wa_lips, wa_output.
l_count = l_count + 1.
ENDLOOP.
Note that ideally, I would like to do the following query to sum up the total quantity (field lgmng), but ABAP doesn't allow to use group by with for all entries:
SELECT vbeln matnr charg SUM( lgmng ) as lgmng meins
FROM lips
INTO TABLE i_lips
FOR ALL ENTRIES IN i_vttp
WHERE vbeln = i_vttp-vbeln
AND aedat LE sy-datum
AND lfimg <> 0
GROUP BY vbeln matnr charg meins.
Any help would be appreciated. Thank you.
There are several problems with your code:
A select in a loop is generally a bad idea since it increases database accesses(which you really don't want ) . Consider other options like joins.
The reason why you get only the last line is that in every loop pass( in the loop where you do a select ) the internal table i_lips gets overwritten and hence on exiting the loop, you get only the last selected entries. To solve this you could modify your select query as follows:
SELECT vbeln
matnr
charg
SUM( lgmng ) as lgmng
meins
FROM lips
APPENDING TABLE i_lips
WHERE vbeln = wa_vttp-vbeln
AND aedat LE sy-datum
AND lfimg <> 0
GROUP BY vbeln, matnr, charg, meins.

Value in dropdown box isn't refreshed

I have a dynpro screen with two input fields:
The sales order n°
The sales order line n° (in a dropdown list)
My problem is that the sales order line isn't refreshed after a different sales order n° is input. However the other output fields relating to the sales order line are properly refreshed with the expected data.
Program behavior:
"Document vente" is "Sales order". "Poste" is "Line number".
From this screen, If I request sales order number 1, the order line 10 remains active and shows up in the dropdown list, despite order number 1 not having a line number 10. The other output fields are updated with the data of line 20. If I pick line orders 20, 30 or 70, the value 10 disappears from the list.
The dynpro screen fields are named as their corresponding fields from the VBAK and VBAP tables, so that their values are copied automatically from one to another.
The code followed by the comment "Set order line to first one in the order" doesn't seem to work. I expect it to replace the value of the line number field with the first line number in the new order.
The code:
MODULE REFRESH_ALL_FIELDS INPUT.
DATA temp_vbeln TYPE VBAK-VBELN.
temp_vbeln = VBAK-VBELN.
CLEAR: VBAK, VBAP.
SELECT VBELN KUNNR BSTNK NETWR WAERK
FROM VBAK
INTO CORRESPONDING FIELDS OF VBAK
WHERE VBAK~VBELN = temp_vbeln.
ENDSELECT.
" Fill dropdown list with order line numbers.
TYPE-POOLS VRM.
DATA it_posnr TYPE VRM_VALUES.
REFRESH it_posnr.
SELECT POSNR
FROM VBAP
INTO TABLE it_posnr
WHERE VBAP~VBELN = VBAK-VBELN.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = 'VBAP-POSNR'
VALUES = it_posnr
* EXCEPTIONS
* ID_ILLEGAL_NAME = 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.
" Set order line number as first in the order.
SELECT SINGLE POSNR
FROM VBAP
INTO VBAP-POSNR
WHERE VBAP~VBELN = VBAK-VBELN.
PERFORM REFRESH_ITEM_FIELDS.
ENDMODULE. " REFRESH_ALL_FIELDS INPUT
MODULE REFRESH_ITEM_FIELDS INPUT.
PERFORM REFRESH_ITEM_FIELDS.
ENDMODULE. " REFRESH_ITEM_FIELDS INPUT
FORM REFRESH_ITEM_FIELDS .
SELECT SINGLE MATNR ARKTX KWMENG
FROM VBAP
INTO CORRESPONDING FIELDS OF VBAP
WHERE VBAP~VBELN = VBAK-VBELN
AND VBAP~POSNR = VBAP-POSNR.
ENDFORM. " REFRESH_ITEM_FIELDS
Flow logic:
PROCESS BEFORE OUTPUT.
PROCESS AFTER INPUT.
FIELD VBAK-VBELN MODULE REFRESH_ALL_FIELDS ON REQUEST.
FIELD VBAP-POSNR MODULE REFRESH_ITEM_FIELDS ON REQUEST.
How can I fix this ?
The dynpro flow logic statement FIELD vbak-vbeln MODULE ... ON REQUEST permits only to change "easily" the value of the screen field VBAK-VBELN, i.e. the value of the global variable VBAK-VBELN will be "transported" in both directions, from the screen to the ABAP program, and vice versa.
If you want to change another screen field, like VBAP-POSNR, you must call the function module DYNP_VALUES_UPDATE:
TYPES tt_dynpread TYPE STANDARD TABLE OF dynpread WITH DEFAULT KEY.
DATA(dynpfields) = VALUE ty_dynpread_s(
( fieldname = 'VBAP-POSNR'
fieldvalue = vbap-posnr ) ).
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
TABLES
dynpfields = dynpfields
EXCEPTIONS
OTHERS = 8.
Another solution is to declare a "chain" of fields, you may then change those fields directly inside the module without calling DYNP_VALUES_UPDATE:
CHAIN.
FIELD: vbak-vbeln, vbap-posnr.
MODULE ... ON REQUEST.
ENDCHAIN.
But that would require to execute the same code for both fields.
Here is the way how you can do it without creating a dynpro, just with pure selection screen:
TYPES: BEGIN OF ty_order,
vbeln TYPE vbak-vbeln,
erdat TYPE vbak-erdat,
netwr TYPE vbak-netwr,
kunnr TYPE vbak-kunnr,
END OF ty_order,
BEGIN OF ty_pos,
vbeln TYPE vbap-vbeln,
posnr TYPE vbap-posnr,
matnr TYPE vbap-matnr,
arktx TYPE vbap-arktx,
kwmeng TYPE vbap-kwmeng,
END OF ty_pos.
DATA: i_order TYPE TABLE OF ty_order WITH EMPTY KEY,
i_pos TYPE TABLE OF ty_pos WITH EMPTY KEY,
i_aux TYPE TABLE OF ty_pos WITH EMPTY KEY,
list TYPE vrm_values.
PARAMETERS: order TYPE vbak-vbeln AS LISTBOX VISIBLE LENGTH 80 USER-COMMAND ord,
position TYPE vbap-posnr AS LISTBOX VISIBLE LENGTH 80 USER-COMMAND art.
INITIALIZATION.
SELECT vbeln erdat netwr kunnr
FROM vbak AS ak
INTO TABLE i_order
WHERE vbeln = ANY ( SELECT vbeln FROM vbap WHERE vbeln = ak~vbeln GROUP BY vbeln HAVING COUNT( * ) > 1 ).
IF i_order IS NOT INITIAL.
SELECT vbeln posnr matnr arktx kwmeng
FROM vbap
INTO TABLE i_pos
FOR ALL ENTRIES IN i_order
WHERE vbeln = i_order-vbeln.
ENDIF.
LOOP AT i_order INTO DATA(wa).
APPEND VALUE vrm_value( key = |{ wa-vbeln ALPHA = OUT }| text = |{ wa-erdat DATE = USER }| ) TO list.
ENDLOOP.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'order'
values = list.
CLEAR list.
AT SELECTION-SCREEN.
CHECK sy-ucomm = 'ORD'.
CLEAR position.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'position'
values = list.
CLEAR list.
AT SELECTION-SCREEN ON order.
CHECK sy-ucomm = 'ORD' AND order IS NOT INITIAL.
i_aux = VALUE #( FOR pos IN i_pos WHERE ( vbeln = |{ order ALPHA = IN }| ) ( pos ) ).
LOOP AT i_aux INTO DATA(aux).
APPEND VALUE vrm_value( key = |{ aux-posnr ALPHA = OUT }| text = |{ aux-matnr ALPHA = OUT }| ) TO list.
ENDLOOP.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'position'
values = list.
After each selection in order dropdown all the order-related data will be collected to i_aux table which you can use for populating output fields.
The closest solution was to update a working area in the PAI, and update the actual screen fields in the PBO, from the values of the WA.

Custom Search Help from Application Server Directory ABAP

I have requirement to provider customer search help for user and data to be retrieved from application server directory.
Following is the detail of directory and File type.
Application Server Directory: /usr/sap/tmp/
File type extension .txt should only be available in search help.
Custom Search help should display Directory Name and File having extension .txt.
Users should not be able to select files from any other directory.
Example of Search help output:
Directory Name File Name
-------------- --------------
/usr/sap/tmp/ file_name1.txt
/usr/sap/tmp/ file_name2.txt
/usr/sap/tmp/ file_name3.txt
Following links are helpful but my requirement is not fulfilled.
https://archive.sap.com/discussions/thread/285999
F4_FILENAME
cl_gui_frontend_services=>directory_browse
/SAPDMC/LSM_F4_SERVER_FILE
https://archive.sap.com/discussions/thread/715635
F4_DXFILENAME_TOPRECURSION
is there any one who has better solution?
regards,
Umar Abdullah
Doesn't function module /SAPDMC/LSM_F4_SERVER_FILE fullfil your requirement?
Edit:
In order for users to not be able to select anything from different directories, you can write a wrapper around the function call to make sure the right directory is selected.
Probably not the ideal solution, but one that requires no development effort.
CONSTANTS:
lco_directory TYPE char30 VALUE '/usr/sap/tmp/',
lco_filemask TYPE char5 VALUE '*'.
DATA:
lv_filename TYPE rlgrap-filename,
lv_path TYPE string.
WHILE 1 NE 2.
CLEAR: lv_filename, lv_path.
CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
EXPORTING
directory = lco_directory
filemask = lco_filemask
IMPORTING
serverfile = lv_filename
EXCEPTIONS
canceled_by_user = 1
OTHERS = 2.
IF sy-subrc = 0 AND sy-ucomm NE 'CANC' AND lv_filename IS NOT INITIAL.
CALL FUNCTION 'TRINT_SPLIT_FILE_AND_PATH'
EXPORTING
full_name = lv_filename
IMPORTING
file_path = lv_path
EXCEPTIONS
x_error = 1
OTHERS = 2 .
IF sy-subrc = 0 AND lv_path NE lco_directory.
* Wrong directory was chosen
MESSAGE 'Invalid directory' TYPE 'S' DISPLAY LIKE 'W'.
ELSE.
* Directory is ok
EXIT.
ENDIF.
ELSE.
* Action cancelled
CLEAR: lv_filename, lv_path.
EXIT.
ENDIF.
ENDWHILE.
I have created custom logic for the requirement. I would like to share.
REPORT YUA_LIST_DIRECTORY.
CLASS ff_intf DEFINITION.
PUBLIC SECTION.
METHODS: listdirectory IMPORTING iv_dir TYPE c
EXPORTING ev_ldir TYPE c ev_file TYPE c ,
get_file_list IMPORTING iv_ldir TYPE c iv_today TYPE c.
TYPES: BEGIN OF t_directory,
log_name TYPE dirprofilenames,
phys_path TYPE dirname_al11,
END OF t_directory.
DATA: lt_int_list TYPE TABLE OF abaplist,
lt_string_list TYPE list_string_table,
lt_directories TYPE TABLE OF t_directory,
ls_directory TYPE t_directory.
DATA: BEGIN OF gs_file,
directory(500) TYPE c, " name of directory.
name(75) TYPE c, " name of entry." (possibly truncated.)
type(10) TYPE c, " type of entry: directory, file
len(16) TYPE p, " length in bytes
owner(8) TYPE c, " owner of the entry
mtime(6) TYPE p, " last modification date, " seconds since 1970
mode(9) TYPE c, " like "rwx-r-x--x":" protection mode
errno(3) TYPE c,
errmsg(40) TYPE c,
mod_date TYPE d,
mod_time(8) TYPE c, " hh:mm:ss
subrc LIKE sy-subrc,
END OF gs_file.
DATA:
ls_file LIKE gs_file,
pt_file LIKE TABLE OF gs_file.
CLASS-METHODS: p6_to_date_time_tz IMPORTING iv_time TYPE p EXPORTING ev_time TYPE c ev_date TYPE d.
ENDCLASS. "ff_intf DEFINITION
*----------------------------------------------------------------------*
* CLASS ff_intf IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS ff_intf IMPLEMENTATION.
METHOD listdirectory.
FIELD-SYMBOLS: <l_line> TYPE string.
CONCATENATE 'FF' sy-datum '.txt' INTO ev_file. " file name
SUBMIT rswatch0 EXPORTING LIST TO MEMORY AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = lt_int_list.
CALL FUNCTION 'LIST_TO_ASCI'
EXPORTING
with_line_break = 'X' "abap_true
IMPORTING
list_string_ascii = lt_string_list
TABLES
listobject = lt_int_list.
* remove the separators and the two header lines
DELETE lt_string_list WHERE table_line CO '-'.
DELETE lt_string_list INDEX 1.
DELETE lt_string_list INDEX 1.
* parse the individual lines
LOOP AT lt_string_list ASSIGNING <l_line>.
* If you're on a newer system, you can do this in a more elegant way using regular expressions
CONDENSE <l_line>.
SHIFT <l_line> LEFT DELETING LEADING '|'.
SHIFT <l_line> RIGHT DELETING TRAILING '|'.
SPLIT <l_line>+1 AT '|' INTO ls_directory-log_name ls_directory-phys_path.
APPEND ls_directory TO lt_directories.
ENDLOOP.
READ TABLE lt_directories INTO ls_directory WITH KEY log_name = iv_dir .
IF sy-subrc EQ 0.
ev_ldir = ls_directory-phys_path.
ENDIF.
ENDMETHOD. "listdirectory
METHOD get_file_list.
DATA:
l_counter TYPE i,
l_counter_package TYPE i,
l_char10(10),
l_text(100),
l_subrc LIKE sy-subrc,
lv_cmptoday TYPE c LENGTH 11.
*-----------------------------------*
DATA lv_compstr TYPE c LENGTH 5.
lv_compstr = '*.TXT'.
CONCATENATE '*' sy-datum+0(4) sy-datum+4(2) sy-datum+6(2) '*' INTO lv_cmptoday. " YYYYMMDD
CALL 'C_DIR_READ_FINISH'
ID 'ERRNO' FIELD ls_file-errno
ID 'ERRMSG' FIELD ls_file-errmsg.
CALL 'C_DIR_READ_START'
ID 'DIR' FIELD iv_ldir " logical directory
ID 'FILE' FIELD '*'
ID 'ERRNO' FIELD ls_file-errno
ID 'ERRMSG' FIELD ls_file-errmsg.
IF sy-subrc <> 0.
IF NOT ls_file-errmsg IS INITIAL.
MESSAGE i034(/sapdmc/lsmw_obj_060) WITH ls_file-errmsg.
ENDIF.
EXIT.
ENDIF.
DO .
CLEAR ls_file.
CALL 'C_DIR_READ_NEXT'
ID 'TYPE' FIELD ls_file-type
ID 'NAME' FIELD ls_file-name
ID 'LEN' FIELD ls_file-len
ID 'OWNER' FIELD ls_file-owner
ID 'MTIME' FIELD ls_file-mtime
ID 'MODE' FIELD ls_file-mode
ID 'ERRNO' FIELD ls_file-errno
ID 'ERRMSG' FIELD ls_file-errmsg.
l_subrc = sy-subrc.
ls_file-subrc = sy-subrc.
IF l_subrc = 1.
EXIT.
ELSEIF l_subrc = 5.
ls_file-type = '???'.
ls_file-owner = '???'.
ls_file-mode = '???'.
ENDIF.
ls_file-directory = iv_ldir.
ADD 1 TO l_counter.
ADD 1 TO l_counter_package.
IF l_counter_package = 100.
l_text = '& Enteries Read'.
l_char10 = l_counter.
REPLACE '&' WITH l_char10 INTO l_text.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
text = l_text.
l_counter_package = 0.
ENDIF.
* Machine time into date/time of day convert
IF iv_today EQ 'X'. " only files of current date
CALL METHOD ff_intf=>p6_to_date_time_tz( EXPORTING iv_time = ls_file-mtime
IMPORTING ev_time = ls_file-mod_time ev_date = ls_file-mod_date ).
IF ls_file-mod_date EQ sy-datum.
* Only the files, which fit the sample(mask)
CASE ls_file-type(1).
WHEN 'F' OR 'f'. " File
IF ( ls_file-name CP lv_compstr ) AND ls_file-name+0(2) = 'FF' AND ls_file-name CP lv_cmptoday. " Only Text File to compare
APPEND ls_file TO pt_file.
ENDIF.
* WHEN OTHERS.
* APPEND ls_file TO pt_file.
ENDCASE.
ENDIF.
ELSE. " ALL files in directory
* Only the files, which fit the sample(mask)
CASE ls_file-type(1).
WHEN 'F' OR 'f'. " File
IF ( ls_file-name CP lv_compstr ) AND ls_file-name+0(2) = 'FF'. " Only Text File to compare and PODEL & Today
APPEND ls_file TO pt_file.
ENDIF.
ENDCASE.
ENDIF.
ENDDO.
SORT pt_file BY type DESCENDING name DESCENDING.
CALL 'C_DIR_READ_FINISH'
ID 'ERRNO' FIELD ls_file-errno
ID 'ERRMSG' FIELD ls_file-errmsg.
ENDMETHOD. "get_file_list
METHOD p6_to_date_time_tz.
DATA: opcode TYPE x,
unique, not_found,
timestamp TYPE i,
date TYPE d,
time TYPE t,
tz LIKE sy-zonlo,
timestring(10),
abapstamp(14),
abaptstamp TYPE timestamp.
timestamp = iv_time.
IF sy-zonlo = space.
* Der Benutzer hat keine Zeitzone gepflegt: nehme lokale des App. Srv.
CALL FUNCTION 'TZON_GET_OS_TIMEZONE'
IMPORTING
ef_timezone = tz
ef_not_unique = unique
ef_not_found = not_found.
IF unique = 'X' OR not_found = 'X'. .
tz = sy-tzone.
CONCATENATE 'UTC+' tz INTO tz.
ENDIF.
ELSE.
tz = sy-zonlo.
ENDIF.
* wandle den Timestamp in ABAP Format um und lass den ABAP konvertieren
opcode = 3.
CALL 'RstrDateConv'
ID 'OPCODE' FIELD opcode
ID 'TIMESTAMP' FIELD timestamp
ID 'ABAPSTAMP' FIELD abapstamp.
abaptstamp = abapstamp.
CONVERT TIME STAMP abaptstamp TIME ZONE tz INTO DATE date
TIME time.
IF sy-subrc <> 0.
date = abapstamp(8).
time = abapstamp+8.
ENDIF.
WRITE: time(2) TO timestring(2),
':' TO timestring+2(1),
time+2(2) TO timestring+3(2),
':' TO timestring+5(1),
time+4(2) TO timestring+6(2).
MOVE timestring TO ev_time.
MOVE date TO ev_date.
ENDMETHOD. "P6_TO_DATE_TIME_TZ
ENDCLASS.
DATA lo_pi TYPE REF TO ff_intf.
DATA ls_pt LIKE LINE OF lo_pi->pt_file.
DATA v_csv TYPE c LENGTH 1 VALUE space.
DATA v_separator TYPE c LENGTH 2.
DATA: lt_file TYPE ztt_file,
ls_file LIKE LINE OF lt_file,
ls_ptfile LIKE LINE OF lo_pi->pt_file.
SELECTION-SCREEN: BEGIN OF BLOCK a WITH FRAME TITLE text-001.
PARAMETERS p_dir TYPE c LENGTH 50 DEFAULT '/usr/sap/tmp/'.
PARAMETERS: p_sfile LIKE rlgrap-filename.
SELECTION-SCREEN: END OF BLOCK a.
AT SELECTION-SCREEN OUTPUT.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_sfile.
REFRESH lo_pi->pt_file.
CALL METHOD lo_pi->get_file_list( EXPORTING iv_ldir = p_dir iv_today = '' ). " Directory logical name.
REFRESH lt_file.
LOOP AT lo_pi->pt_file INTO ls_ptfile.
MOVE ls_ptfile-directory TO ls_file-directory.
MOVE ls_ptfile-name TO ls_file-fname.
APPEND ls_file TO lt_file.
ENDLOOP.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'FNAME'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'so_tmpl-low'
value_org = 'S'
TABLES
value_tab = lt_file
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
CASE sy-subrc.
WHEN 1.
MESSAGE 'Parameter Error' TYPE 'I' DISPLAY LIKE 'W'.
WHEN 2.
MESSAGE 'No values found' TYPE 'I' DISPLAY LIKE 'W'.
WHEN 3.
MESSAGE 'Error Processing help' TYPE 'I' DISPLAY LIKE 'W'.
ENDCASE.
********************************* INITIALIZATION. ************************************
INITIALIZATION.
CREATE OBJECT lo_pi.
********************************* START-OF-SELECTION ************************************
START-OF-SELECTION.
********************************* END-OF-SELECTION ************************************
END-OF-SELECTION.

Selection screen parameter with a dynamic matchcode

I have a serie of entry parameters where there a match code, I need that this field (matchcode) will be dependent of a text parameter. For example, something like that :
SELECTION-SCREEN BEGIN OF BLOCK block02 WITH FRAME TITLE text-002.
PARAMETERS:
p_mona TYPE ZTIPOSOL GROUP rad1 MATCHCODE OBJECT ZFIMC002,
p_fcomp TYPE SY-DATUM MODIF ID A OBLIGATORY.
SELECTION-SCREEN END OF BLOCK block02
ABAP Development
No, you cannot. However, you can populate search help values dynamically in AT SELECTION-SCREEN ON VALUE-REQUEST event:
DATA: LT_VBAK TYPE STANDARD TABLE OF VBAK.
PARAMETER P_VBELN TYPE VBELN.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VBELN.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = 'VBELN'
DYNPPROG = SY-REPID
DYNPNR = SY-DYNNR
DYNPROFIELD = 'P_VBELN'
VALUE_ORG = 'S'
TABLES
VALUE_TAB = LT_VBAK
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
where LT_VBAK is a internal table you need to populate with values.
If your values are dependent on another selection screen parameter, use DYNP_VALUES_READ FM to read them from screen.
Another approach is not to dynamically fill values but to create a single Search Help in DDIC and create Search Help exit which will control SHELP behavior depending on some conditions.

What is the difference between OCCURS 0 and TYPE STANDARD TABLE

I am new to ABAP, and I am creating ALV using FM 'REUSE_ALV_FIELDCATALOG_MERGE' and 'REUSE_ALV_GRID_DISPLAY'.
It is working when I defined internal table IT_MARD using obsolete occurs 0 definition. But I am getting Exception condition "NO_FIELDCATALOG_AVAILABLE" raised, when I defined internal table using type standard table. Could you please explain difference between these two definition and why it is not working in the latter case. The following is the code.
REPORT ztest_fieldcatalog3.
TYPE-POOLS:slis.
*Semi Automatic Fieldcatalog Generation.
*DATA: BEGIN OF IT_MARD OCCURS 0,
* MATNR LIKE MARD-MATNR,
* WERKS LIKE MARD-WERKS, ""
* LGORT LIKE MARD-LGORT,
* PSTAT LIKE MARD-PSTAT,
* END OF IT_MARD.
TYPES: BEGIN OF ty_mard,
matnr type mard-matnr,
werks type mard-werks,
lgort type mard-lgort,
pstat type mard-pstat,
END OF ty_mard.
DATA: IT_MARD TYPE STANDARD TABLE OF ty_mard.
"Use function module create Fieldcat.
DATA:l_program TYPE sy-repid VALUE sy-repid.
DATA:i_fieldcat TYPE slis_t_fieldcat_alv.
SELECT matnr
werks
lgort
pstat
FROM mard
INTO CORRESPONDING FIELDS OF TABLE it_mard
UP TO 100 ROWS.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = l_program
i_internal_tabname = 'IT_MARD'
i_inclname = l_program
i_bypassing_buffer = 'X'
CHANGING
ct_fieldcat = i_fieldcat[].
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
"Call ALV and pass fieldcatalog and data
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_program
it_fieldcat = i_fieldcat
TABLES
t_outtab = it_mard.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
The difference is that OCCURS creates a table with a header line, while TYPE STANDARD TABLE OF does not (unless you explicitly tell it to). I suppose that the function module is able to guess the structure from a table with a header line, but not a table without a header line. My suggestions would be to
use a data dictionary structure instead of a local structure - it's easier to maintain and extend later on and
don't use the REUSE function modules, but check the CL_SALV_* classes instead since they are officially supported and have a much cleaner API