2012年12月30日 星期日

Finding the CHPID for a device

To find the CHPID for a device use the display command:

  D M=DEV(xxxx)


  IEE174I 09.51.34 DISPLAY M 470
  DEVICE 0B02   STATUS=OFFLINE
  CHP                   C0
  PATH ONLINE           Y
  CHP PHYSICALLY ONLINE Y
  PATH OPERATIONAL      N
  PATHS NOT VALIDATED

Reconfiguring CHPIDs for devices

If you have reconfigurable devices (non-shared) and you want to move
them from one system to another:

1)  Find the devices on the CHPID:

    D M=CHP(xx)

 IEE174I 09.30.51 DISPLAY M 163
 CHPID C0:  TYPE=12, DESC=OPEN SYSTEMS ADAPTER
 DEVICE STATUS FOR CHANNEL PATH C0
     0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
 0B0 +  $@ $@ $@ $@ $@ .  .  .  .  .  .  .  .  .  .
 0BF .  .  .  .  .  .  .  .  .  .  .  .  .  .  +  .
 ************************ SYMBOL EXPLANATIONS ************************
 + ONLINE    @ PATH NOT VALIDATED   - OFFLINE    . DOES NOT EXIST
 * PHYSICALLY ONLINE   $ PATH NOT OPERATIONAL


2)  Vary the devices offline:

    V xxxx-yyyy,OFFLINE


3)  Configure the CHPID offline:

    CF CHP(xx),OFFLINE


4)  On the other system, configure the CHPID online:

    CF CHP(xx),ONLINE


5)  Vary the devices online:

    V xxxx-yyyy,ONLINE

2012年12月12日 星期三

Dynamic create UIWebView

CGRect webFrame = CGRectMake(0.0, 0.0, 400.0, 460.0);
UIWebView *webView = [[UIWebView alloc] initWithFrame:webFrame];
[webView setBackgroundColor:[UIColor greenColor]];
webView.scalesPageToFit = YES;    // setting scales page to fit

NSString* htmlString = [NSString stringWithContentsOfFile:finalPath encoding:NSUTF8StringEncoding error:nil];

[webView loadHTMLString:htmlString baseURL:nil];
[self.view addSubview:webView];

2012年11月30日 星期五

Objective-C – Sleep Function

In Objective-C, you can use the sleepForTimeInterval class method of NSThread to sleep the program.
// Sleep the program for 10 second
[NSThread sleepForTimeInterval:10.0];

2012年11月23日 星期五

Multi-line UITableViewCell using UILabel

No need for UITextViews or custom UITableViewCells. You can use standard UITableViewCellStyles and make the detailTextLabel accept multiple lines and specify its line break mode. The code would be:

static NSString *CellIdentifier = @"MyCell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2
     reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = @"Label';
cell.detailTextLabel.text = @"Multi-Line\nText";
cell.detailTextLabel.numberOfLines = 2;
cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;

You will also need to return a suitable height for the multi-line cell. A height of (44.0 + (numberOfLines - 1) * 19.0) should work fine.

2012年11月11日 星期日

Dynamic UILabel

- (void)loadView
{
    [super loadView];
    //1.UILable的大小自适应实例:
    UILabel *myLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 2, 2)];//设定位置与大小
    [myLabel setFont:[UIFont fontWithName:@"Helvetica" size:20.0]];//格式
    [myLabel setNumberOfLines:0];//行数,只有设为0才可以自适应
    [myLabel setBackgroundColor:[UIColor clearColor]];//背景色
    myLabel.shadowColor = [UIColor darkGrayColor];//阴影颜色
    myLabel.shadowOffset = CGSizeMake(1.0,1.0);//阴影大小
    
    NSString *text = @"abcdefghigklmnopqrstuvwxyz";
    UIFont *font = [UIFont fontWithName:@"Helvetica" size:20.0];
    CGSize size = [text sizeWithFont:font constrainedToSize:CGSizeMake(175.0f, 2000.0f) lineBreakMode:UILineBreakModeWordWrap];
    CGRect rect=myLabel.frame;
    rect.size=size;
    [myLabel setFrame:rect];
    [myLabel setText:text];
     myLabel.shadowColor = [UIColor darkGrayColor];//阴影颜色
     myLabel.shadowOffset = CGSizeMake(2.0,2.0);//阴影大小
    [self.view addSubview:myLabel];
    [myLabel release];
    //2.UILable的基本用法获取自馒头MAN百度空间,感谢馒头MAN
            //空间地址:http://hi.baidu.com/bunsman/blog/item/95777b0ebacf05fe36d122e2.html
    UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 40.0, 200.0, 30.0)];     
    UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 80.0, 200.0, 50.0)];     
    UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 140.0, 200.0, 50.0)];     
    UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 200.0, 200.0, 50.0)];     
    UILabel *label5 = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 260.0, 200.0, 50.0)];     
    UILabel *label6 = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 320.0, 200.0, 50.0)];     
    UILabel *label7 = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 380.0, 200.0, 50.0)];     
    
    //设置显示文字     
    label1.text = @"label1";     
    label2.text = @"label2";     
    label3.text = @"label3--label3--label3--label3--label3--label3--label3--label3--label3--label3--label3--11个";     
    label4.text = @"label4--label4--label4--label4--4个";     
    label5.text = @"label5--label5--label5--label5--label5--label5--6个";     
    label6.text = @"label6";     
    label7.text = @"label7";     
    
    //设置字体:粗体,正常的是 SystemFontOfSize     
    label1.font = [UIFont boldSystemFontOfSize:20];     
    
    //设置文字颜色  
    label1.textColor = [UIColor orangeColor];     
    label2.textColor = [UIColor purpleColor];     
    //设置背景颜色 
    label1.backgroundColor = [UIColor clearColor];
    label2.backgroundColor = [UIColor  colorWithRed:0.5f green:30/255.0f blue:0.3f alpha:0.5f];
    //设置文字位置     
    label1.textAlignment = UITextAlignmentRight;     
    label2.textAlignment = UITextAlignmentCenter;     
    //设置字体大小适应label宽度     
    label4.adjustsFontSizeToFitWidth = YES;
    //设置label的行数     
    label5.numberOfLines = 2;     
    
    //设置高亮     
    label6.highlighted = YES;     
    label6.highlightedTextColor = [UIColor orangeColor];     
    
    //设置阴影     
    label7.shadowColor = [UIColor redColor];     
    label7.shadowOffset = CGSizeMake(1.0,1.0);     
    
    //设置是否能与用户进行交互     
    
    label7.userInteractionEnabled = YES;     
    
    //设置label中的文字是否可变,默认值是YES     
    label3.enabled = NO;     
    
    //设置文字过长时的显示格式     
    
    label3.lineBreakMode = UILineBreakModeMiddleTruncation;//截去中间     
    //  typedef enum {     
    //      UILineBreakModeWordWrap = 0,     
    //      UILineBreakModeCharacterWrap,     
    //      UILineBreakModeClip,//截去多余部分     
    //      UILineBreakModeHeadTruncation,//截去头部     
    //      UILineBreakModeTailTruncation,//截去尾部     
    //      UILineBreakModeMiddleTruncation,//截去中间     
    //  } UILineBreakMode;     
    
    //如果adjustsFontSizeToFitWidth属性设置为YES,这个属性就来控制文本基线的行为     
    label4.baselineAdjustment = UIBaselineAdjustmentNone;     
    //  typedef enum {     
    //      UIBaselineAdjustmentAlignBaselines,     
    //      UIBaselineAdjustmentAlignCenters,     
    //      UIBaselineAdjustmentNone,     
    //  } UIBaselineAdjustment;     
    
    
    [self.view addSubview:label1];     
    [self.view addSubview:label2];     
    [self.view addSubview:label3];     
    [self.view addSubview:label4];     
    [self.view addSubview:label5];     
    [self.view addSubview:label6];     
    [self.view addSubview:label7];     
    
    [label1 release];     
    [label2 release];     
    [label3 release];     
    [label4 release];     
    [label5 release];     
    [label6 release];     
    [label7 release];         
    
}

2012年10月20日 星期六

CICS TS 4.2 for z/OS Messages & Codes iPhone version

Find this APP "CICS TS messages and Codes"

2012年9月29日 星期六

Create a Quick Response Code (QR Code) image using Google Chart

Here is an example of generating a QR code image for the My developerWorks iphone app on iTunes: "<"img src="https://chart.googleapis.com/chart?chs=250x250&cht=qr&chl=http://itunes.apple.com/us/app/developerworks/id391162970?mt=8&choe=UTF-8" alt="Download developerWorks app" /">" Download developerWorks app QR codes have a different set of required parameters from any other chart:

2012年9月7日 星期五

iPhone Socket Programing in Objective-C

“What is Socket programming.”? So it is simply a way to communicate with two machines using UDP and TCP/IP protocol. Socket are interfaces that allows you to transfer data in bidirectional way means from one app to another app. Socket has two sides. Each side of it is identified by a combination of IP address and port. Socket programing is used in various situation in iOS for iPad, iPod and iPhone application development like on line gaming, chat application etc. There are lots of guides and articles available to make socket connection between apps but these are very limited in Objective-C and it is very complicated to integrate them. This article discusses only how we can create a socket connection from one app to another app. After establishing the connection both apps can send and receive data to and from each other. Socket Programming in Objective-C can be described in 3 parts: 1. Setting Socket Connection 2. Reading from Socket Connection 3. Writing to Socket Connection For detailed implementation of these 3 parts of Socket Programming refer to: Socket_Programing_for_IOS.pdf

2012年8月28日 星期二

2012年8月2日 星期四

iPhone socket sample

client.... #import #include #include #include #include #include #import void dealWithData(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info) { /* printf("received %d bytes from socket %d\n", CFDataGetLength((CFDataRef)data), CFSocketGetNative(s)); */ UInt8 buffer[100]; CFDataGetBytes((CFDataRef)data, CFRangeMake(0,CFDataGetLength((CFDataRef)data)),buffer); printf("%s\n",(char*)buffer); } main () { CFSocketRef s = CFSocketCreate(NULL, PF_INET, SOCK_STREAM, IPPROTO_TCP, kCFSocketDataCallBack, dealWithData, NULL); CFDataRef address, data; struct sockaddr_in sin; char message[] = "Insert message to send here.\n"; CFRunLoopSourceRef source; memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_port = htons(8880); address = CFDataCreate(NULL, (char *)&sin, sizeof(sin)); data = CFDataCreate(NULL, message, sizeof(message)); CFSocketConnectToAddress(s, address, 0); CFSocketSendData(s, NULL, data, 0); CFRelease(address); CFRelease(data); source = CFSocketCreateRunLoopSource(NULL, s, 0); CFRunLoopAddSource(CFRunLoopGetCurrent(), source, kCFRunLoopDefaultMode); CFRelease(source); CFRelease(s); CFRunLoopRun(); }

2012年6月8日 星期五

The function to replace string in C

#include 
#include 

char * replace(
    char const * const original, 
    char const * const pattern, 
    char const * const replacement
) {
  size_t const replen = strlen(replacement);
  size_t const patlen = strlen(pattern);
  size_t const orilen = strlen(original);

  size_t patcnt = 0;
  const char * oriptr;
  const char * patloc;

  // find how many times the pattern occurs in the original string
  for (oriptr = original; patloc = strstr(oriptr, pattern); oriptr = patloc + patlen)
  {
    patcnt++;
  }

  {
    // allocate memory for the new string
    size_t const retlen = orilen + patcnt * (replen - patlen);
    char * const returned = (char *) malloc( sizeof(char) * (retlen + 1) );

    if (returned != NULL)
    {
      // copy the original string, 
      // replacing all the instances of the pattern
      char * retptr = returned;
      for (oriptr = original; patloc = strstr(oriptr, pattern); oriptr = patloc + patlen)
      {
        size_t const skplen = patloc - oriptr;
        // copy the section until the occurence of the pattern
        strncpy(retptr, oriptr, skplen);
        retptr += skplen;
        // copy the replacement 
        strncpy(retptr, replacement, replen);
        retptr += replen;
      }
      // copy the rest of the string.
      strcpy(retptr, oriptr);
    }
    return returned;
  }
}

#include 
int main(int argc, char * argv[])
{
  if (argc != 4)
  {
    fprintf(stderr,"usage: %s   \n", argv[0]);
    exit(-1);
  }
  else
  {
    char * const newstr = replace(argv[1], argv[2], argv[3]);
    if (newstr)
    {
      printf("%s\n", newstr);
      free(newstr);
    }
    else
    {
      fprintf(stderr,"allocation error\n");
      exit(-2);
    }
  }
  return 0;
}

2012年5月18日 星期五

BPXWDYN Documentation


Introduction to BPXWDYN
BPXWDYN is a text interface to a subset of the SVC 99 (dynamic allocation) and SVC 109 (dynamic output) services. BPXWDYN supports data set allocation, unallocation, concatenation, and adding and deleting output descriptors.

The primary intent of this function is to make dynamic allocation and dynamic output services easily accessible by programs running outside of a TSO environment, however, this also functions in a TSO environment.

An output descriptor is associated with a SYSOUT allocation by using the OUTDES key on the SYSOUT allocation request or by creating a default output descriptor.

The syntax for allocation is quite similar to TSO for the TSO ALLOCATE and FREE commands. It should be possible to provide parameters to BPXWDYN that would be acceptable as a TSO ALLOCATE or FREE command. There are keys that TSO ALLOC supports that are not currently supported by BPXWDYN. There are also some keys that can be used with BPXWDYN that are not compatible with TSO.

The syntax for accessing dynamic output facilities is similar to the TSO OUTDES command, but identifying the name of the output descriptor is not the same.

BPXWDYN is an existing internal function within OpenEdition services. This document describes how to access it and use it. Some keywords listed in this document are not available at all levels of OpenEdition. A release level will be noted on those keys. A version of BPXWDYN is also available via FTP. This version supports all keywords. It is contained in an unloaded load library so it should be downloaded in binary format and copied to an MVS system into an FB 80 data set. It is restored using TSO/E RECEIVE:

  receive inda(your.dataset.name)

It can replace BPXWDYN in SYS1.LINKLIB, be placed in a data set ahead of this in your linklist, or be loacated in your STEPLIB.


--------------------------------------------------------------------------------

Calling Conventions
BPXWDYN is designed to be called from REXX, but may also be called by any program. Three parameter list forms are supported.


REXX External Function Parameter List
This parameter list allows REXX programs to call the BPXWDYN programs as a function or subroutine. They must be called with a single string parameter:

   if BPXWDYN("alloc dd(sysin) da('my.dataset') shr")<>0 then
      call allocfailed


Conventional MVS Variable Length Parameter String
This is the same parameter list as is generated by ADDRESS LINKMVS with one parameter and JCL with EXEC PGM=,PARM=. This parameter list form is simple to use by any program. Note that this is a single item variable length parameter list. The high bit is on in the parameter address word and length is a half word.


Figure 1.


 
      *-*------------------*
 R1-->|1| parm string addr *---*
      *-*------------------*   |
       *-----------------------*
       |     *-------*---------------------*
       *---->| length| parameter string    |
             *---*---*---------------------*
 




PL/I usage might include the following statements:

  DCL PLIRETV BUILTIN;
  DCL BPXWDYN EXTERNAL ENTRY OPTIONS(ASM INTER RETCODE);
  DCL ALLOC_STR CHAR(100) VAR
        INIT('ALLOC FI(SYSIN) DA(MY.DATASET) SHR');
  FETCH BPXWDYN;
  CALL BPXWDYN(ALLOC_STR);


Null Terminated String Parameter
This parameter list is used most easily from C passing a string to BPXWDYN defined with a #pragma for OS linkage, or extern "OS" for C++. Note that the high bit is on in the parameter address word.


Figure 2.


 
      *-*------------------*
 R1-->|1| parm string addr *---*
      *-*------------------*   |
       *-----------------------*
       |     *----------------------*---*
       *---->|  parameter string    |00x|
             *----------------------*---*
 




C usage might include the following statements:

  typedef int EXTF();
  #pragma linkage(EXTF,OS)
  EXTF *bpxwdyn;
  int  rc;
  bpxwdyn=(EXTF *)fetch("BPXWDYN");
  rc=bpxwdyn("alloc fi(sysin) da(my.dataset) shr");


--------------------------------------------------------------------------------

General Usage

--------------------------------------------------------------------------------

Request Types
The request is specified in a string parameter. The following request types are supported:

ALLOC
Dynamic allocation of a data set
FREE
Dynamic unallocation of a DD name or free an output descriptor
CONCAT
Dynamic concatenation of a DD name list
OUTDES
Create an output descriptor
The request type should be the first keyword in the parameter string. If a valid request type is not the first keyword, the request type defaults to ALLOC.


--------------------------------------------------------------------------------

Keywords
The ordering of keywords on the request can be arbitrary.

Keys cannot be specified multiple times for one request.

BPXWDYN does no consistency checking on keys. If some keys are not valid together on a single request, dynamic allocation or dynamic output will fail the request.

Some keywords accept arguments. Keyword arguments must be specified within parenthesis. Spaces are not permitted between the key and the opening parenthesis or anywhere within the additional argument string through the closing parenthesis unless the argument string is quoted. Spaces are permitted between key specifications. Where multiple arguments are permitted, the arguments must be separated by commas.

An argument may be enclosed within quotes. Either single (') or double (") quotes may be used. Two adjacent quotes cannot be used to represent a single quote within a quoted string.

Arguments that are not quoted are treated as upper case. Arguments that are quoted are only treated as mixed case if it makes sense for the keyword.


--------------------------------------------------------------------------------

Return Codes
When BPXWDYN is called as a REXX function or subroutine, the return code can be accessed in RESULT or as the value of the function. When called as a program, the return code is available in R15.

BPXWDYN returns the following codes:

0
Success
20
Invalid parameter list. See Calling Conventions for parameter list formats.
-21 to -9999
Key error
-100nn
Message processing error. IEFDB476 returned code nn.
>0
Dynamic allocation or dynamic output error codes

Understanding Key Errors
The low order two digits is the number of the key that failed the parse, offset by 20. The first key will have the value 21.

The high order two digits is a diagnostic code that indicates where in the code the parse failed. If the high digits are 0, the key itself was probably not recognized. Other values usually indicate a problem with the argument for the failing keyword. Likely causes are blanks in arguments that are not quoted and spelling of key names.


Understanding Dynamic Allocation Error Codes
The return code contains the dynamic allocation error reason code in the high two bytes and the information reason code in the low two bytes.

You can use the high four hex digits to lookup the error code in the dynamic allocation error reason codes table found in the Application Development Guide for Authorized ASM Programs.


Understanding Dynamic Output Error Codes
The return code contains the dynamic output return code in the high two bytes (S99ERROR) and the information code (S99INFO) in the low two bytes.

You can use the high four hex digits to lookup the error code in the dynamic output return codes table found in the Application Development Guide for Authorized ASM Programs and the low four digits to look up the information code.

There is no indication of the key that is in error.

Some of the most likely reason codes are:

300-30C,312,380
Make sure the arguments are specified correctly
401
The output descriptor already exists
402
The output descriptor does not exist
403
Output descriptors created by JCL cannot be deleted by dynamic output
Messages are not produced for dynamic output errors.


--------------------------------------------------------------------------------

Message processing
Dynamic allocation provides message text for failed allocation requests. It is usually easier to use this message text rather than decode allocation return codes.

BPXWDYN can return these messages to a REXX program. By default the messages are returned in the S99MSG. stem. S99MSG.0 contains the number of messages and S99MSG.1, ... contains the message text.

The name of the stem can be changed by using the MSG key. A stem is not required. Digits are simply appended to the variable specified by the MSG key.

The MSG key can also be used to request allocation to issue the messages to your job log (write to programmer using WTO).

Under OpenMVS, messages can be written to opened files by providing the file descriptor number as the argument to MSG. MSG(2), for example, will write messages to the STDOUT file.

No support is provided to directly output messages to a user.


--------------------------------------------------------------------------------

Using the Dynamic Allocation Request
To request dynamic allocation, specify alloc at the beginning of the parameter string.

BPXWDYN supports single data set allocation. Many of the common allocation keys can be used. Some additional keys are also supported to access additional functions.

The following keys are supported:


DD(DDname)

FI(DDname)

DDname to free or allocate


RTDDN(variable)

Return allocated DDname into the REXX variable variable. Available in OS390 R8


DA(data set name[(member name)])

DSN(data set name[(member name)])

Data set name to allocate. The name must be fully qualified and may include a member name. Quotes can be used for TSO compatability.


RTDSN(variable)

Return allocated data set name into the REXX variable variable. Available in OS390 R8


MOD

NEW

OLD

SHR

Specifies the data set status


CATALOG

DELETE

KEEP

UNCATALOG

Specifies the data set disposition


TRACKS

Space is to be allocated by tracks


CYL

Space is to be allocated by cylinders


BLOCK

Space is to be allocated by blocks Available in OS390 R10


DIR(directory blocks)

Number of directory blocks


SPACE(primary[,secondary])

Specifies primary and optionally secondary space allocations


VOL(volser [,volser...])

VOLSER specification. A list of volumes is available in R10


MAXVOL(num vols)

Number of volumes for a multi-volume data set. Available in R10


RTVOL(variable)

Return allocated volume name into the REXX variable variable. Available in OS390 R8


UNIT(unit name)

Specifies unit name, device type, or unit address


SYSOUT[(class)]

Specifies that a sysout data set is to be allocated and optionally defines the output class


SUBSYS(subsys name[,subsys parm]...)

Directs the allocation request to subsys name. with optional parameters. Case is preserved for quoted parms, otherwise the parm is upper-cased. Null parameters can also be specified by leaving a subsys parm empty. Availability not yet targeted for product


WRITER(external writer name)

Names the external writer


FORMS(forms name name)

Specifies the print form


DEST(destination)

Specifies the output destination


DEST(node[.user])

Specifies the output destination and node Available in OS390 R7


COPIES(number of copies)

Specifies the number of copies to print


DUMMY

Allocate a dummy data set


BLKSIZE(block size)

Specify the block size


LRECL(record length)

Specifies the logical record length


DSORG(PS|PO|DA)

Specifies the data set organization


RECFM(format[,format...])

Specifies the record format. The valid values are: A, B, D, F, M, S, T, U and V. Several may be used in combination.


BUFNO(number)

Set number of buffers. This number should be in the range 1-255. Numbers outside that range will give unpredictable results. Available in OS390 R9


OUTDES(output descriptor name)

Output descriptor name


STORCLAS(storage class)

Specifies the storage class


MGMTCLAS(management class)

Specifies the management class


DATACLAS(data class)

Specifies the data class


RECORG(LS)

Create a VSAM linear data set


DSNTYPE(LIBRARY|PDS|HFS)

Specifies the data set type


SPIN(UNALLOC)

Spin off a sysout data set at unallocation


MSG(WTP|default.S99MSG.|stemname|fdnum)

Direct allocation messages to your job log (WTP), a REXX stem, or a file identified by a file descriptor number. If this key is not specified, messages will be returned in the S99MSG. stem, if possible. If the program was not called by a REXX exec, the messages will be lost.

NORECALL

Fail the allocation request if the data set is migrated

PATH(pathname)

Pathname to allocate.

PATHOPTS(path options list)

Set options for pathname allocation. This list is a list of keywords separated with commas. The supported keywords are: ORDWR OEXCL OSYNC OTRUNC OCREAT OWRONLY ORDONLY OAPPEND ONOCTTY ONONBLOCK.

PATHMODE(path mode list)

Set mode bits for a new allocation. This list is a list of keywords separated with commas. The supported keywords are: SIRUSR SIWUSR SIXUSR SIRWXU SIRGRP SIWGRP SIXGRP SIRWXG SIROTH SIWOTH SIXOTH SIRWXO SISUID SISGID SISVTX.

PATHPERM(octal path mode)

Set mode bits for a new allocation. This key is effectively the same as PATHMODE but accepts a simple octal number for the mode bit settings.

PATHDISP(KEEP|DELETE[,KEEP|DELETE])

Specifies file disposition for normal and abnormal termination of the job step. Available in OS390 R3

FILEDATA(TEXT|BINARY)

Tells the sequential access method services whether the data is to be treated as text or binary. Available in OS390 R5

REUSE

Causes the named DD to be freed before the function is performed. Available in OS390 R5

SHORTRC

If the dynamic allocation fails, the dynamic allocation error code (S99ERROR) is returned in R15 and the information code is not returned. This is useful is the application can only process R15 as a half word, such as PL/I. Available in OS390 R6

--------------------------------------------------------------------------------

Using the FREE Request for Dynamic Unallocation
To request dynamic unallocation, specify free at the beginning of the parameter string.

BPXWDYN supports single data set unallocation. Most common unallocation keys can be used. The following keys are supported:


DD(DDname)

FI(DDname)

DDname to free


DA(data set name[(member name)])

DSN(data set name[(member name)])

Data set name to free. The name must be fully qualified and may include a member name. Quotes are optional.


CATALOG

DELETE

KEEP

UNCATALOG

Overrides the disposition


SYSOUT(class)

Overrides the output class


SPIN(UNALLOC)

Spin off the sysout data set at unallocation


MSG(WTP|default.S99MSG.|stemname|fdnum)

Direct allocation messages to your job log (WTP), a REXX stem, or a file identified by a file descriptor number. If this key is not specified, messages will be returned in the S99MSG. stem, if possible. If the BPXWDYN was not called by a REXX exec, the messages cannot be returned in a stem. WTP should be specified to obtain messages.

SHORTRC

If the dynamic allocation fails, the dynamic allocation error code (S99ERROR) is returned in R15 and the information code is not returned. This is useful is the application can only process R15 as a half word, such as PL/I. Available in OS390 R6

--------------------------------------------------------------------------------

Using the Dynamic Concatenation Request
To request dynamic concatenation, specify concat at the beginning of the parameter string.

This function concatenates multiple DDs to a single DD. The DDs are concatenated in the order specified in the DDLIST key. The following keys are supported:


CONCAT

Command verb to concatenate data sets identified by DD names If no command verb is specified, ALLOC is assumed.


DDLIST(DDname1,DDname2[,DDnamex...] )

Specify a list of DD names to concatenate to DDname1. This key should be used with the CONCAT key.


MSG(WTP|default.S99MSG.|stemname|fdnum)

Direct allocation messages to your job log (WTP), a REXX stem, or a file identified by a file descriptor number. If this key is not specified, messages will be returned in the S99MSG. stem, if possible. If the program was not called by a REXX exec, the messages will be lost.

SHORTRC

If the dynamic allocation fails, the dynamic allocation error code (S99ERROR) is returned in R15 and the information code is not returned. This is useful is the application can only process R15 as a half word, such as PL/I. Available in OS390 R6

--------------------------------------------------------------------------------

Using the Dynamic Output Request
To request dynamic output, specify outdes at the beginning of the parameter string. This keyword takes an argument that names the output descriptor. The keyword is described below.

The following keys are supported:


OUTDES(descriptor name)

Names the output descriptor to be added. This must be the first key specified in the parameter string.


ADDRESS(address[,address...])

Specifies the delivery address. Dynamic output will allow up to four arguments to be specified.


BUILDING(building)

Specifies the building location


BURST

Directs output to a stacker


CHARS(chars[,chars...])

Names the character arrangement tables.


CLASS(class)

Assigns the SYSOUT class.


CONTROL(spacing)

Specifies line spacing or that the records begin with carriage control characters. The valid values are:
Single
Single spacing
Double
Double spacing
Triple
Triple spacing
Program
Records begin with carriage control characters


COPIES(number of copies)

Specifies the number of copies to be printed.


DEFAULT

Specifies that this is a default output descriptor.


DEPT(department)

Specifies the department identification.


DEST(node[.user])

Send the SYSOUT to the specified destination.


DPAGELBL

Specifies that a security label be placed on the output.


FCB(fcb name)

Specifies the FCB image.


FLASH

Specifies the forms overlay.


FORMDEF(formdef name)

Names the formdef.


FORMS(forms name)

Names the forms to print on.


MODIFY(trc number)

Specifies which character arrangement table is to be used.


NAME(owner name)

Specifies the owner's name.


NOTIFY([node.]user)

Sends print completion message to the destination.


OUTDISP(disposition)

Specifies the data set disposition.


PAGEDEF(pagedef name)

Names the pagedef.


PRMODE(print mode)

Identifies the process mode (LINE or PAGE).


ROOM(room identification)

Specifies the room identification.


TITLE(separator title)

Specifies the separator page title.


TRC

Specifies that the data set contains TRC codes.


UCS(UCS name)

Names the UCS or character arrangement table.


WRITER(external writer name)

Names an external writer to process the data set.


--------------------------------------------------------------------------------

Using the FREE Request to Free an Output Descriptor
To request that an output descriptor be freed, specify free at the beginning of the parameter string.

Only one keyword is supported


OUTDES(descriptor name)

Names the output descriptor to be freed.


--------------------------------------------------------------------------------

Examples

--------------------------------------------------------------------------------

Examples Calling BPXWDYN from REXX

Allocate SYS1.MACLIB to SYSLIB directing messages to OpenMVS stderr
 
    call bpxwdyn "alloc fi(syslib) da(sys1.maclib) shr msg(2)"


Free SYSLIB and trap messages in stem S99MSG.
 
    call bpxwdyn "free fi(syslib)"


Concatenate SYS1.SBPXEXEC to SYSPROC
 
    if bpxwdyn("alloc fi(tmp) da(sys1.sbpxexec) shr msg(2)")=0 then
       call bpxwdyn "concat ddlist(sysproc,tmp) msg(2)"


Create descriptor P20 with distribution information
 
   call bpxwdyn "outdes(p20) dest(kgn.p20n10)",
               "address('WJ Schoen','M/S 619')",
               "name(wschoen) bin(0004) dept(64ba)"


Free descriptor P20
 
   call bpxwdyn "free outdes(p20)"


--------------------------------------------------------------------------------

Examples Calling BPXWDYN from C

Free descriptor P20

Allocate SYS1.MACLIB to SYSLIB directing messages to OpenMVS stderr
 
   typedef int EXTF();
   #pragma linkage(EXTF,OS)
 
   int call_alloc()
   {
   EXTF *bpxwdyn=(EXTF *)fetch("BPXWDYN");
   return bpxwdyn("alloc fi(syslib) da(sys1.maclib) shr msg(2)")
   }

2012年5月10日 星期四

Start and browse file resoure definition sample

EXEC CICS INQUIRE FILE START END-EXEC.         
PERFORM UNTIL RESPCODE = DFHRESP(END)           
    EXEC CICS INQUIRE FILE(FILENAME) NEXT       
        OPENSTATUS(OPENSTAT)                   
        RECOVSTAT(RCVRSTAT)                     
        FWDRECSTATUS(FWDSTAT)                   
        RESP(RESPCODE) END-EXEC                 
    IF RESPCODE = DFHRESP(NORMAL)               
        IF OPENSTAT = DFHVALUE(OPEN)           
            CALL RCVY-RTN USING RCVRSTAT FWDSTAT
        END-IF                                 
    ELSE CALL ERROR-RTN END-IF                 
END-PERFORM.                                   
EXEC CICS INQUIRE FILE END END-EXEC.

How to get RACF information in CICS region


CICS doesn’t supply much access directly to RACF info via the API. But there is a supported way to obtain a lot of RACF information about the current user. And it can be done in plain ol’ COBOL.

EXEC CICS ADDRESS ACEE will provide access to the RACF ACEE control block. (ACEE stands for Access Control Environment Element. Maybe it will come up in a trivia question some day. Probably not. The important thing to know is that it is a block of storage containing RACF information which can be addressed from application programs.) From there, it is possible to easily obtain the user’s primary RACF group and the user’s name (as it is recorded in RACF).

The layout of the ACEE control block is documented in SYS1.MACLIB(IHAACEE). Unfortunately, there is not a COBOL copybook provided, so to access this information in a COBOL program, we have to code our own storage definitions. The following are based on SYS1.MACLIB(IHAACEE):

Define these in Linkage area
01 ACEE.
05 FILLER PIC X(021).
05 ACEEUSRI PIC X(008).
05 FILLER PIC X(001).
05 ACEEGRPN PIC X(008).
05 FILLER PIC X(062).
05 ACEEUNAM-POINTER USAGE IS POINTER.
01 ACEE-USER-NAME.
05 FILLER PIC X(001).
05 ACEEUNAM PIC X(020).

And we need a piece of miscellaneous working storage to hold a pointer:

77 WS-ACEE-ADDR-POINTER USAGE IS POINTER.
Now, if we execute the following, we’ll have the address of the ACEE control block in that pointer:

EXEC CICS
ADDRESS ACEE (WS-ACEE-ADDR-POINTER)
END-EXEC.
And then the following commands will make the RACF information addressable by our storage definitions:

SET ADDRESS OF ACEE TO WS-ACEE-ADDR-POINTER.
SET ADDRESS OF ACEE-USER-NAME TO ACEEUNAM-POINTER.
Now we have the user’s RACF id in ACEEUSRI, the user’s primary RACF group in ACEEGRPN, and the user’s name in ACEEUNAM. Very simple – just a matter of knowing how to address the information.

In a future post, we’ll continue this and see how we can obtain all of the RACF groups to which the user’s RACF id is connected.

2012年5月9日 星期三

How to Link COBOL & C Together on z/OS

(1) Link your C program to call your COBOL program by declaring your C and COBOL functions as follows:

 Declare a function in C that passes an integer value (i) to COBOL:
 void CBLRTN(int );
 CBLRTN(i);

 Use the value “I” from the C program in your COBOL program:
 01 I PIC S9(9) BINARY.
 PROCEDURE DIVISION USING BY VALUE I.

(2) Link your COBOL program to your C program by having the COBOL program call a C function and pass it a value, as follows:

Call the C subroutine “CFUNC” from COBOL, passing the value “I”:
01 I PIC S9(9) BINARY.
CALL "CFUNC" USING BY VALUE I.

Declare the function in C:
void CFUNC(int i) {
  return i;
}

(3) Declare a “pragma_linkage” at the top of your C program to explicitly declare a linkage to COBOL, which is required by some compilers. The syntax for the pragma linkage is:
“#pragma linkage(function, COBOL)”.

You declare the pragma linkage and create a C function to pass a value to COBOL as follows:

#pragma linkage(CBLRTN,COBOL)
void CBLRTN(int i);
CBLRTN(i);

You then use the passed variable in your COBOL program as follows:

01 I PIC S9(9) USAGE IS BINARY
PROCEDURE DIVISION USING I.

(4) Declare a “pragma linkage” at the top of your C program to explicitly link the COBOL program to C. This is
required by some compilers. The pragma linkage is always done in the C program, even when the COBOL program is
passing the value to the C program.

You declare the variable in the COBOL program and call the C function as follows:

01 I PIC S9(9) USAGE IS BINARY
CALL 'CFUNC' USING BY CONTENT I.

You then declare the pragma linkage to COBOL and define the function in C as follows:

#pragma linkage(CFUNC,COBOL)
void CFUNC(int p1) {

2012年4月30日 星期一

Migrating data from HFS/zFS to zFS

Suppose you have an HFS file system mounted at /etc/dfs. You want to copy this into an empty zFS file system mounted at /etc/dce/testzfs1. You issue the following commands from z/OS UNIX:
(1) Move to the source (HFS) file system mounted at /etc/dfs
cd /etc/dfs

(2) Create a z/OS UNIX archive file called /tmp/zfs1.pax that contains the HFS file system mounted at /etc/dfs
pax -wvf /tmp/zfs1.pax .

(3) Move to the target (zFS) file system mounted at /etc/dce/testzfs1
cd /etc/dce/testzfs1

(4) Read the archive file into the zFS file system mounted at /etc/dce/testzfs1
pax -rv -p e -f /tmp/zfs1.pax

2012年4月26日 星期四

CICS without security in an ACF2

F ENF,MODE(CICS,NONE) and set SEC=NO in SIT or override, the region(s) will come up without ACF2

2012年4月11日 星期三

C - replace substring


char *replace_str(char *str, char *orig, char *rep)
{
static char buffer[4096];
char *p;

if(!(p = strstr(str, orig))) // Is 'orig' even in 'str'?
return str;

strncpy(buffer, str, p-str); // Copy characters from 'str' start to 'orig' st$
buffer[p-str] = '\0';

sprintf(buffer+(p-str), "%s%s", rep, p+strlen(orig));

return buffer;
}

Example:
replace_str("Hello, world!", "world", "Miami@ #")

2012年4月5日 星期四

C - string padding


char *StringPadRight(char *string, int padded_len, char *pad) {
int len = (int) strlen(string);
if (len >= padded_len) {
return string;
}
int i;
for (i = 0; i < padded_len - len; i++) {
strcat(string, pad);
}
return string;
}

that's supposed to do StringPadRight("Hello", 10, "0") -> "Hello00000".

2012年3月13日 星期二

Converts ACF2 UID(LID) based Rules to LID based ROLES


RULE2ROLE

/* REXX EXEC */
/* Converts ACF2 Rulesets to Rolesets
- All Rule Lines must be written to the LID

- To execute:
1) Change the LIDPARMS variables:
- LIDSTART = Starting Position of LID in UID String
- LIDLENGTH = Length of LID
*/
lidstart = 17
lidlength = 8
/*
1) Change the Dataset Names:
- IN_DATASET = Unloaded Rules
- OUT_DATASET = Converted Roles
*/
in_dataset = 'KLERO03.ACF2.RULES.SEQ'
out_dataset = 'KLERO03.ACF2.ROLES.SEQ'
/*

Revision History:

Date Changes
-------- ------------------------------------------------
20100705 B.Kleamovich - Initial Release
*** End of Revision History
*/
trace o
/* */
/*Mainline - Start */
call define_vars
call read_file
call process_file
call write_file
say "Output has" j "lines"
Exit 0
/*Mainline - End */
/* */
define_vars:
Out. = ' '
i = 0
j = 0
k = 0
l = 0
x = 0
y = 0
ts = '----+----0'
tt = ts||ts||ts||ts||ts
sp = ' '
sp = sp||sp||sp||sp
sp = substr(sp,1,46)
return
/* */
read_file:
"ALLOC F(INPUT) DA('"||in_dataset||"') SHR REUSE"
"EXECIO * DISKR INPUT (STEM DATA. FINIS"
"FREE F(INPUT)"
return
/* */
process_file:
Do i=1 to Data.0
if pos('$KEY(',strip(data.i,both)) > 0 then
do
j = j + 1
out.j = strip(data.i,both)|| ' ROLESET '
iterate
end
if pos('UID(*)',strip(data.i,both)) > 1 then
do
parse var data.i what who other
role = 'LID(*)'
j = j + 1
out.j = ' ' what role other
iterate
end
if pos('UID(',strip(data.i,both)) > 1 then
do
parse var data.i what who other
who = strip(who,both)
spos = lidstart + 4
epos = lidlength
lid = substr(who,spos,epos)
/* say ' ' tt
say ' WHO: ' who
say 'SPOS: ' spos
say 'EPOS: ' epos
say ' LID: ' lid
say */
if pos(')',lid) > 1 then
do
k = pos(')',lid)
lid = strip(substr(lid,1,k - 1),both)
end
if pos('*',lid) > 1 then
do
k = pos('*',lid)
lid = strip(substr(lid,1,k - 1),both)
end
role = 'LID('||lid||')'
j = j + 1
out.j = ' ' what role other
iterate
end
j = j + 1
out.j = data.i
end
return
/* */
write_file:
"ALLOC F(OUTPUT) DA('"||out_dataset||"') OLD REUSE"
"EXECIO "j" DISKW OUTPUT (STEM OUT. FINIS"
"FREE F(OUTPUT)"
return
/*

2012年3月5日 星期一

The program returns the volume with the master catalog


/* REXX ***************************************************************/
/* Master Cat Info */
/**********************************************************************/
cvt = Storage(10,4) /* Get the CVT address */
amcbs = Storage(D2x(256+C2d(cvt)),4) /* Get the AMCBS address */
acb = Storage(D2x(8+C2d(amcbs)),4) /* Get the ACB address */
caxwa = Storage(D2x(64+C2d(acb)),4) /* Get the CAXWA address */
dsncat = Storage(D2x(52+C2d(caxwa)),44) /* Dsn of Master Cat */
dsncat = Strip(dsncat,T) /* */
ucbcat = Storage(D2x(28+C2d(caxwa)),4) /* UCB name for Master Cat*/
volcat = Storage(D2x(28+C2d(ucbcat)),6) /* Volume for Master Cat */
Say dsncat" on "volcat
exit

The program calculates the CPU performance of a system in MIPS


/* REXX */
CVT = STORAGE(10,4)
RMCT = STORAGE(D2X(C2D(CVT)+604),4)
SU = STORAGE(D2X(C2D(RMCT)+64),4)
SU = 16000000/C2D(SU)
SAY 'SU/SEC FACTOR IS' SU ,
'(1 CPU SECOND EQUALS' SU 'SERVICE UNITS)'
CVTPCCAT = STORAGE(D2X(C2D(CVT)+764),4)
SAY 'PCCA VECTOR TABLE AT' C2X(CVTPCCAT)
I = 0
P = 0
SAY '----------------------------------------'
SAY ' PROC VERSION CPUID MODEL PCCA '
SAY 'NUMBER CODE ADDRESS'
SAY '----------------------------------------'
DO WHILE I < 16
PCCA = STORAGE(D2X(C2D(CVTPCCAT)+I*4),4)
IF PCCA ^= '00000000'X THEN DO
PCCAPCCA = STORAGE(D2X(C2D(PCCA)),4)
PCCAVC = STORAGE(D2X(C2D(PCCA)+4),2)
PCCACPID = STORAGE(D2X(C2D(PCCA)+6),6)
PCCAMDL = STORAGE(D2X(C2D(PCCA)+12),4)
IF PCCAPCCA = 'PCCA' THEN DO
SAY ' ' I ' ' PCCAVC ' ' PCCACPID ,
' '!!PCCAMDL ' ' C2X(PCCA)
P = P + 1
END
END
I = I + 1
END
IF P > 1 THEN PROCS = 'PROCESSORS'
ELSE PROCS = 'PROCESSOR'
SAY
SAY P PROCS 'IN THIS COMPLEX'
MIPS = SU/48.5
SAY
SAY '** TOTAL MIPS :' MIPS*P
IF P > 1 THEN SAY ,
'** EQUIVALENT UNIPROCESSOR MIPS :' MIPS
/* */
/* MSU EVALUATION */
/* */
MSU = SU*P*3600/1000000
SAY FORMAT(MSU,,0) 'MSU (FOR PSLC PRICING -'

2012年2月11日 星期六

How to display messages to SYSOUT from CICS program

1. Define an extra partition TDQ as shown below.

I TDQ(CSSL)
RESULT - OVERTYPE TO MODIFY
Tdqueue(CSSL)
Type(Extra)
Nameind()
Triggerlevel( )
Enablestatus( Enabled )
Openstatus( Open )
Termid()
Tranid()
Userid()
Disposition(Mod)
Iotype(Output)
Indoubt()
Indoubtwait()
Databuffers(001)
Ddname(MSGUSR)
Dsname(DXXC01.CICTTEST.S0006329.D0000110.?)
Member()
+ Installtime(12/06/11 18:31:55)

2. In the CICS statup job code "//MSGUSR DD SYSOUT=*"

3. Write the messages from your application program to that TDQ. Whatever you write to the TDQ from your application will appear in the SYSOUT.

2012年1月29日 星期日

Call REXX program from COBOL program


IBM supplied routine "IRXJCL" can be used to call a REXX program from a COBOL program.

ID DIVISION.
PROGRAM-ID. CBLTRX.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 CALL-IRXJCL PIC X(6) VALUE "IRXJCL" .
01 CALL-PARM.
05 PARM-LEN PIC S9(4) BINARY VALUE 6.
05 PARM-VALUE PIC X(6) VALUE "REXPGM".
*
PROCEDURE DIVISION.
CALL CALL-IRXJCL USING CALL-PARM.
DISPLAY "RETURN CODE = " RETURN-CODE.
STOP RUN.


JCL to execute the module


//STEP0001 EXEC PGM=CBLTRX
//STEPLIB DD DISP=SHR,DSN=&SYSUID..COBOL.LOAD
//SYSEXEC DD DISP=SHR,DSN=&SYSUID..REXX
//SYSOUT DD SYSOUT=*
//*

2012年1月21日 星期六

REXX DO Loop

Processing can be controlled in a DO loop in a number of ways:
ITERATE :Stops processing in a loop and returns to the start of the loop and
continues with the next item in the loop.
LEAVE :Stops processing the DO loop, and continues processing with the
next instruction after the loop.
LEAVE label :Stops processing a DO loop inside another DO loop returning
processing to DO loop with 'label' as the counter
                                                                             
E.g DO O = 1 to 10
DO n = 1 to 10
DO m = 1 to 10
if m = 2 then ITERATE /* go back to m */
if m = 5 then LEAVE /* go back to n */
if m = 7 then LEAVE O /* go back to O */
end
end
end

Chinese New Year



I would like to wish you all a happy Chinese New year!

2012年1月12日 星期四