{"id":28174,"date":"2022-03-07T10:52:07","date_gmt":"2022-03-07T09:52:07","guid":{"rendered":"https:\/\/help.qualiware.it\/qw-help\/?p=28174"},"modified":"2022-03-07T10:52:28","modified_gmt":"2022-03-07T09:52:28","slug":"generazione-movimenti-di-magazzino-da-movimento-di-intervento","status":"publish","type":"post","link":"https:\/\/help.qualiware.it\/qw-help\/generazione-movimenti-di-magazzino-da-movimento-di-intervento\/","title":{"rendered":"Generazione movimenti di magazzino da movimento di intervento"},"content":{"rendered":"<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">' Il seguente snippet mostra come sia possibile generare movimenti di magazzino tramite un task a partire dal materiale registrato in un movimento di intervento\r\n' Nell'esempio il magazzino di prelievo si chiama \"MGES\" e la causale utilizzata \u00e8 \"SCA\".\r\ndim QWSess as QWSession\r\nQWSess=DB.QWSession\r\nMovMag_Apertura_Archivi(QWSess)\r\n\r\ndim q as new qwTable()\r\n\r\nq.database=DB\r\nq.sql=\"select distinct * from MOVMAG where CANC=0 and TIPODOC='**' and NUMDOC like 'MS%' and not exists (select * from RICREVST where NUMDOC='MS'+replace(ricrevst.NUMMOV,' ','0') and movmag.CODART=ricrevst.CODART and  QTMOV=QTA)\"\r\nq.requestlive=false\r\nq.active=true\r\n\r\ndim ok as boolean\r\nwhile not q.rowset.endofset \r\n\tok=MovMag_Elimina(QWSess,q.rowset.fields(\"TIPODOC\").value,q.rowset.fields(\"NUMDOC\").value)\r\n\tif not ok\r\n\t   Write_LogDoc(QWSess,\"**\",\"QDAEMON\",100,\"Errore cancellando il movimento di magazzino da assistenza \"+q.rowset.fields(\"NUMDOC\").value)\r\n\tEnd If\r\n\tq.rowset.next()\r\nend while\r\n\r\nq.active=false\r\nq.sql=\"select r.NUMMOV,r.CODART,r.QTA,m.DATA from RICREVST r join MOVSTRUM m on m.NUMMOV=r.NUMMOV where m.DATA&gt;convert(datetime,'07\/03\/2022',103) and not exists(select * from MOVMAG where CANC=0 and TIPODOC='**' and NUMDOC='MS'+replace(r.NUMMOV,' ','0') and movmag.CODART=r.CODART and QTMOV=QTA)\"\r\nq.requestlive=false\r\nq.active=true\r\ndim errmsg as string\r\nwhile not q.rowset.endofset()\r\n   ok=MovMag_Crea_Nuovo(QWSess, q.rowset.fields(\"CODART\").value,\"SCA\", \"MGES\", \"\", \"**\", \"MS\"+replace(q.rowset.fields(\"NUMMOV\").value,\" \",\"0\"), q.rowset.fields(\"QTA\").value,0,nothing,dttod(q.rowset.fields(\"DATA\").value),errmsg)\r\n   \r\n   if not ok\r\n      errmsg=\"Errore nella generazione del movimento di magazzino da assistenza per il movimento n. \"+q.rowset.fields(\"NUMMOV\").value+\": \"+errmsg   \r\n      Write_LogDoc(QWSess,\"**\",\"QDAEMON\",100,errmsg)\r\n   end if   \r\n      \r\n   q.rowset.next()\r\nend while\r\nq.active=false<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\">&nbsp;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8216; Il seguente snippet mostra come sia possibile generare movimenti di magazzino tramite un task a partire dal materiale registrato in un movimento di intervento &#8216; Nell&#8217;esempio il magazzino di prelievo si chiama &#8220;MGES&#8221; e la causale utilizzata \u00e8 &#8220;SCA&#8221;. dim QWSess as QWSession QWSess=DB.QWSession MovMag_Apertura_Archivi(QWSess) dim q as new qwTable() q.database=DB q.sql=&#8221;select distinct *&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"ngg_post_thumbnail":0,"footnotes":""},"categories":[65],"tags":[82],"acf":[],"_links":{"self":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/28174"}],"collection":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/comments?post=28174"}],"version-history":[{"count":0,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/posts\/28174\/revisions"}],"wp:attachment":[{"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/media?parent=28174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/categories?post=28174"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/help.qualiware.it\/qw-help\/wp-json\/wp\/v2\/tags?post=28174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}