‎2013 Aug 23 4:31 PM
Hello Everyone
Well, according to my design I have 2 radiobuttons for 0167 Infotype (PA20/ PA30 Tcodes) namely DENT and MEDI. If the user selects DENT radiobutton an ITAB of 30 fields must be taken into consideration, whereas if 'MEDI' radiobutton is selected a different ITAB of only 6 fields have to be taken.(Well obviously both these ITABs belong to two different structures).
I'm uploading a .txt onto the SAP system(through GUI_UPLOAD). The requirement being if user enters a .txt corresponding to 'DENT' and selects Radiobutton 'MEDI', then an error message should be displayed, the same being for vice versa condition.
I'm not able to get how to use the IF condition in this case.(because the .txt file needs to be recognised) I'm able to take the Radiobutton condition in IF but the other condition for Filename is where I'm getting stuck up. Guys please help me.
Approach used:-
I used the FM 'GET_COMPONENT_LIST' to count the total no of fields of entered Input File for the particular structure, but in vain. Any kind of help will be well received. Thanks
Cheers
Shreyas
(GMIP and TDIP are the 2 subtypes configured in the Client System. Since, I'm trying this code on the Local System, the respective subtypes are DENT and MEDI)
‎2013 Aug 23 5:31 PM
So a logic like :
Open file
Read first record
Close file
Count fields in record = t_count.
If rdo1 ='X' and t_count <> 30.
send error
else If rdo2 ='X' and t_count <> 6.
send other error
endif.
Is that correct?
‎2013 Aug 23 5:24 PM
Is the user supposed to fill in the PC file path and it is then checked for some characteristic within the file? If so, could you explain further?
Neal
‎2013 Aug 23 5:31 PM
So a logic like :
Open file
Read first record
Close file
Count fields in record = t_count.
If rdo1 ='X' and t_count <> 30.
send error
else If rdo2 ='X' and t_count <> 6.
send other error
endif.
Is that correct?
‎2013 Aug 24 1:09 AM
Hi,
First do your upload in the AT SELECTION-SCREEN event. Then the logic would be read the file or rather upload the file with GUI_UPLOAD then.
Read the first line with READ and INDEX. Then Split based on the separator say into a work area that has 30 fields each say text of length 20 chars (or what ever is max length this is just to validate). Then check the 7th field in the work area if it is blank its the file with 6 fields and if not its the file with 30. Give you message and as its AT SELECTION SCREEN user gets it on the screen
Cheers,
Arindam
‎2013 Aug 24 4:39 PM
Hi Neal
Exactly the logic which you have mentioned is exactly going on in my mind, but there is no need of any record to be read, I believe. All I want to do is count the total no of fields in the table, and place a count for it.
Shreyas.
‎2013 Aug 24 4:40 PM
Hi Arindam
Sounds good.
Can you please give me a better insight with the help of some pseudo/layman code, as the object delivery date is somewhere round the corner, and this is the only issue I'm facing right now.
Thanks
Shreyas.
‎2013 Aug 25 1:30 AM
Hi,
The upload can go like:
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = gv_fpath
filetype = 'ASC'
CHANGING
data_tab = gt_line_itm
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Then do the following considering there is no header data :
READ gt_line_itm INTO wa_line_itm INDEX 1.
Split the work area data based on separator. Assumption are the columns are separated by comma or space. Also
wa_line_itm
should have structure like
TYPES: BEGIN OF x_line_itm,
line(10000) TYPE c,
END OF x_line_itm.
The split logic with w_30fields as a structure with 30 fileds each say type C and length 40.
SPLIT w_line_itm AT gc_sep INTO w_30fields-field1
w_30fields-field2
w_30fields-field3
w_30fields-field4
w_30fields-field5
.... goes on till 30 fields
IN CHARACTER MODE.
Then check field 7
IF w_30fields-field7 IS space the file is 6 columns. Thats all
Cheers,
Arindam
‎2013 Aug 24 1:04 PM
Hi Shreyas,
Create one third structure where u will input your .txt file from gui_upload . take this structure as 30 fields . Once the data is uploaded read the first row 7 column , if this is initial then u have a file that is of MEDI type , Just to be sure u can go and check 2-3 columns weather values are initial or not.
this will confirm you about the file being input is MEDI or DENT. Handle the Consequent logic accordingly.
Regards
Arpit Gupta