ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

STRPCO in a C# application

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • STRPCO in a C# application

    Hello guys, i am using C# to call a CL program that uses STRPCO, but i am getting an error that this command isn't allowed. Is there a workaround for this?
    I have read about RUNRMTCMD, but i want the program to be called from a server so i don't know if i will have issues with the Incoming Remote Command feature due to security.

    Basically what i am trying to do is to call the pc command RFROMPCB to transfer some data to the iseries from some text files that we get each month.

    Docs say that STRPCO is allowed in the following situations:

    * Interactive job (*INTERACT)
    * Interactive program (*IPGM)
    * Using QCMDEXEC, QCAEXEC, or QCAPCMD API (*EXEC)

    I am calling the CL from the cwbx.dll. Maybe if i call a program instead, that does the qcmdexec instead?

  • #2
    Re: STRPCO in a C# application

    hi Fjleon:

    I think you want to use cpyfrmimpf/cpytoimpf, cpyfrmstmf/cpytostmf instead of rfrompcb.
    These utilities do not need to run interactivly.

    Best of Luck
    GLS
    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

    Comment


    • #3
      Re: STRPCO in a C# application

      i don't want the program to run in batch mode, i want the file transfer to finish before running an additional program that will do stuff with the data that has been recently uploaded.
      I planned to use SQL, but i am afraid it would be too slow for this scenario, 100k records are going to be read from a text file and then copy them to files on the iseries.

      The dtt files work perfectly but somehow when using cwbx.dll strpco thinks it is running in batch?

      How would i use the cpyfrmimpf command since the files are on another server and i would have to copy them to the iseries first, which is what i am actually trying to do on the first place?

      Comment


      • #4
        Re: STRPCO in a C# application

        Hi Fjleon:

        I'm definately not an expert here but my understanding is that your C# application is not interactive which is where strpco must be run.
        You don't have to copy to the Iseries then to a physical file. You can use qntc to "map" to your server where the data currently resides.

        Code:
        [B]CPYFRMSTMF FROMSTMF('/QNTC/KRONOS_SHARE/HAPR.TXT') [/B]
        [B]        TOMBR('/QSYS.lib/QS36F.lib/KRONHA.file/KRONHA.mbr') MBROPT(*REPLACE)[/B]
        Here is a sample setup for qntc:
        Because most OS/400 shops also have Windows servers, IBM provides tools to integrate Windows data and objects with OS/400 applications, including the little understood but immensely valuable QNTC file system. QNTC allows OS/400 processes to access Windows server data from OS/400 applications just as if those processes resided on a Windows client machine. Like QDLS


        Best of luck
        GLS
        The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

        Comment


        • #5
          Re: STRPCO in a C# application

          That sounds useful, i will try to get qntc configured to use that as a workaround, thanks!

          Comment


          • #6
            Re: STRPCO in a C# application

            Fjleon:
            Before you get too far down that road check out what happens with decimal positions and packed fields and negative signs with the cpyfrmstmf command. I'm not sure but I think it is a direct copy without consideration for the above. Someone else on this forum may have more experiance here.

            GLS
            The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

            Comment


            • #7
              Re: STRPCO in a C# application

              I think that would actually be in my advantage, since the physical files on the iseries were actually created by a data transfer, therefore the fields are defined this way:

              SRCSEQ ZONED 6 2 6 1
              SRCDAT ZONED 6 0 6 7
              SRCDTA CHAR 88 88 13

              Transfers are done in ASCII mode to the already created physical files.
              In our applications, we don't use the physical files directly since they don't have record formats, rather we use logical files.

              Comment


              • #8
                Re: STRPCO in a C# application

                I have just leaned that the cwbx.dll has a databasetransfer method, both download and upload. this may solve my problem

                Comment


                • #9
                  Re: STRPCO in a C# application

                  cwbx.DatabaseTransfer dt = new cwbx.DatabaseTransfer();
                  dt.UserID = "userid";
                  dt.Password = "password";
                  dt.Upload("iseries","library/name","c:\\directory\\file.txt","");

                  Done! No qntc, no cpyfrmstmf, no CL, no program, no anything, very fast!

                  Comment

                  Working...
                  X