Make WLF_IDOC work on S/4HANA 1709
For those of you who don’t know yet the transaction WLF_IDOC, let’s say it is like a super BD87 that allows to search for IDOCs and to display them in a convenient way. You can change the status, replace values in the different segments and reprocess very easily. It is a great tool which is included in SAP without any additional licence like AIF.
One link that explains quite good the tool is http://saptechnicalguru.com/wlf_idoc/
The transaction was already available in ECC but it has been slightly changed in SAP S/4HANA in order to do a very fast selection using an ABAP Managed Database Procedure (AMDP).The problem is that you get an error if you run it, because the definition of the selection is not valid anymore.
For some reason, the syntax of SQL inside an AMDP view has suffered a serious regression : before you could define an alias for a table that had the same name as the table but this is not possible anymore. OK there is no need to define an alias with the same name… Too bad that there are a lot of SAP standard codings having such aliases. This leads to a syntax error, no need to explain what the result is.
So back to our topic about WLF_IDOC, we should avoid such an error in the AMDP. The generated class is CL_WLF_IDOC_READER_AMDP but you cannot change it in the SAP backend. You have to use the SAP Hana Studio and change the method GET_HEADER_AND_ITEM_DATA. Replace the alias name edidc by something else, for example by adding the prefix loc_ to it. So in the coding you will get:
et_data = SELECT edid4seg.*, a.MANDT AS MANDT_S, a.DOCNUM AS DOCNUM_S, a.LOGDAT , a.LOGTIM , a.COUNTR , a.CREDAT AS CREDAT_S, a.CRETIM AS CRETIM_S, a.STATUS as STATUS_S, a.UNAME , a.REPID , a.ROUTID , a.STACOD , a.STATXT , a.SEGNUM AS SEGNUM_S , a.SEGFLD , a.STAPA1 , a.STAPA2 , a.STAPA3 , a.STAPA4 , a.STATYP , a.STAMQU , a.STAMID , a.STAMNO , a.TID , a.APPL_LOG FROM "EDIDS" AS a INNER JOIN ( SELECT loc_edidc.MANDT AS MANDT, loc_edidc.DOCNUM AS DOCNUM, COUNTER, SEGNUM , SEGNAM , PSGNUM , HLEVEL , DOCREL , STATUS , DOCTYP , DIRECT , RCVPOR , RCVPRT , RCVPRN , RCVSAD , RCVSMN , RCVSNA , RCVSCA , RCVSDF , RCVSLF , RCVLAD , STD , STDVRS , STDMES , MESCOD , MESFCT , OUTMOD , SNDPOR , SNDPRT , SNDPRN , SNDSAD , SNDSMN , SNDSNA , SNDSCA , SNDSDF , SNDSLF , SNDLAD , REFINT , REFGRP , REFMES , ARCKEY , CREDAT , CRETIM , MESTYP , IDOCTP , CIMTYP , RCVPFC , SNDPFC , SERIAL , EXPRSS , UPDDAT , UPDTIM , MAXSEGNUM, TEST, SDATA FROM :lt_edid4 AS loc_edid4, :lt_edidc AS loc_edidc WHERE loc_edid4.docnum = loc_edidc.docnum AND loc_edid4.mandt = loc_edidc.mandt AND loc_edidc.mandt = SESSION_CONTEXT('CLIENT') limit :i_lines ) AS edid4seg ON a.mandt = edid4seg.mandt AND a.docnum = edid4seg.docnum WHERE countr = (SELECT MAX(countr) FROM "EDIDS" WHERE mandt = SESSION_CONTEXT('CLIENT') AND docnum = a.docnum) ORDER BY a.docnum;
Now activate the new version and the transaction will run fine. One more good reason to switch to SAP Hana Studio for those of you still using old fashioned SE80 🙂
NB: I’m not sure if/when this has been corrected in the next versions of S/4HANA. Any additional information is welcome.