cancel
Showing results for 
Search instead for 
Did you mean: 

CSV file mismatching

Former Member
0 Kudos

Hi All,

I have created a layout with two File Uploads(Header and Item) and button. I have to Upload two CSV files with respective uploads i.e., Header and item. These two are having different structures. When i browse the file for header ,item and clicking on button it is uploading.

Now, the issue raise for me when i am uploading Header CSV file in Item or Item CSV file in Header it is throughing dump can any slove this?

How can i restirct this before going to loop.

Thanks & regards

Madhan

Accepted Solutions (0)

Answers (1)

Answers (1)

gill367
Active Contributor
0 Kudos

HI

You can check for the content of file in your programming under a specific format.

and if it is not following the same then you can raise the error message.

when you convert the xstring to string then after that

do this validation check that differentiate the header content from the item before moving formad to storing it somewhere

or applying its value.

and by the way what is the dump that you are getting and check the source extract in st22.

thanks

sarbjeet singh

Former Member
0 Kudos

Hi sarbjeet singh,

Thanks for Ur reply.

Here i am not having any problem with upload a csv file to data base. when i am testing i upload a item file to header , i know that these two are having two diffrent sturctures. after reading a file i want to restrict that if it is different to header structure.

please help me out from this.

with thanks and regards

gill367
Active Contributor
0 Kudos

That's what i am saying just after uploading.you will get it in one Xstring variable.

convert it into String and then check its structure.

do the validation here before proceeding ahead.

thanks

sarbjeet singh

Former Member
0 Kudos

Hi Sarbjeet,

Thanks for ur reply,

I am converting from xsrtring to string then i debug.In Header upload i give the path Item file then throughing to dump. going to st22 i saw it that having fields are mismatched.

Is there any method to check if structures are different showing an error.?

can plz help me out.

With thanks and regards

Madhan

gill367
Active Contributor
0 Kudos

If possible could you post your code of upload button here.

thanks

sarbjeet singh

Former Member
0 Kudos

Hi Sarbjeet,

I am unable to paste here my code it is having more than 600 lines.

1) In this i am using index with numbers like below code later it may get problem for me if they add 20 fileds to solve that too.

LOOP AT lt_item_data INTO lw_item_string.

SPLIT lw_item_string AT ',' INTO TABLE lt_item_field.

***get all the fields of one line

READ TABLE lt_item_field INTO lv_item_field INDEX 1.

ls_item_context-dealer_code = lv_item_field.

READ TABLE lt_item_field INTO lv_item_field INDEX 2.

ls_item_context-claim_type = lv_item_field.

READ TABLE lt_item_field INTO lv_item_field INDEX 3.

ls_item_context-claim_si_no = lv_item_field.

READ TABLE lt_item_field INTO lv_item_field INDEX 4.

ls_item_context-failed_part = lv_item_field.

READ TABLE lt_item_field INTO lv_item_field INDEX 5.

ls_item_context-replaced_part = lv_item_field.

READ TABLE lt_item_field INTO lv_item_field INDEX 6.

ls_item_context-quantity = lv_item_field.

READ TABLE lt_item_field INTO lv_item_field INDEX 7.

ls_item_context-rate_claimed = lv_item_field.

READ TABLE lt_item_field INTO lv_item_field INDEX 8.

ls_item_context-billing_docu = lv_item_field.

READ TABLE lt_item_field INTO lv_item_field INDEX 9.

ls_item_context-billing_date = lv_item_field.

APPEND ls_item_context TO lt_item_context.

ENDLOOP.

2) how can i relaod the page when i click upload button second time.

for the first time i am clicking on button with out uploading any file shows me error msg and after uploading shows succuss msg . if click on button 2nd time page is not reloading / refreshing it is showing same success msg

gill367
Active Contributor
0 Kudos

Hi

Coming to the first porblem first.

Well with the code that you have given i am not able to identlfy whish part is creating problem.

Let me tell you one simple solution.

Go to ST22 check the dump there which is created due to this CSV file mismatch.

there you have something called exception at the top in the red color.

Copy this exception name say in your case is is cx_wd_XXX.

now go to your code for the upload button eventhanlder

surround the piece of code that is causing the exception by try catch block.(if you are not sure surrund the entrie code like this)



method onclick .
TRY.
.....

"your code here as usual whatever you haev written 
"your 600 lines :)

     data result type string.                                                                 "declaring the variables to be used for the error message
     data lo_api_controller     type ref to if_wd_controller.
data lo_message_manager    type ref to if_wd_message_manager.


CATCH CX_WD_XXX.        "HERE you need to write the exception that you are getting in the dump

lo_api_controller ?= wd_This->Wd_Get_Api( ).

CALL METHOD lo_api_controller->GET_MESSAGE_MANAGER
  RECEIVING
    MESSAGE_MANAGER = lo_message_manager
    .
result = 'Uploaded file is not valid.' .
* report message
CALL METHOD lo_message_manager->REPORT_ERROR_MESSAGE
  EXPORTING
    MESSAGE_TEXT             = result
    .           




ENDTRY.
endmethod.


this will do.

now for the second problem. you can raise a new thread explaining it in detail with code you used for displaying

the success message and its location.

thanks

sarbjeet singh

Former Member
0 Kudos

Hi All,

I solved My issue

Thanks for helping me.

With Thanks and Regards